### COCI 2006/2007, Contest #5

## Task LIGA

While the players are resting between sets, the station puts on tedious commercials. Zvonko fires up the teletext feature on his TV set and is reviewing the latest scores and standings in the football league. Always sharp, he has come up with a new mathematical game.

The standings table contains five statistics for each team: the total number of games played, how many of those games the team won, drew and lost, and points earned. A team earns 3 points for every win and 1 point for every draw.

Zvonko noticed that the values of some fields can be determined from the others. Write a program that takes in a table in which the values of some fields are unknown, and fills in the missing fields.

The data for different teams is not related. For example, it is possible that the table says all teams have won all their games (although that is not possible in a real league).

Each team will have played at most 100 games (even though that can be one of the missing fields).

### Input

The first line contains an integer N (1 ≤ N ≤ 1000), the number of teams in the league.

Each of the following N lines contains the 5 fields for one team separated by single spaces, containing the 5 pieces of data as described in the problem statement. Each field contains an integer (at least 0), or the character '?' (question mark) if the value is not known.

The input will be consistent and there will be a unique way to determine the values of the missing fields.

### Output

Output the table with the missing fields filled in.

### Sample Input

5 27 21 3 3 66 27 18 6 3 ? ? 15 5 7 50 ? 14 7 5 ? ? 14 ? 8 47

### Sample Output

27 21 3 3 66 27 18 6 3 60 27 15 5 7 50 26 14 7 5 49 27 14 5 8 47

All Submissions

Best Solutions

**Point Value:** 10 (partial)

**Time Limit:** 1.00s

**Memory Limit:** 32M

**Added:** Jul 14, 2013

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

tankibudson Apr 09, 2017 - 5:38:11 pm UTC Test data wrong?I don't think the test data considers this.

ImaxPurpleon Apr 09, 2017 - 10:03:25 pm UTC Re: Test data wrong?The following test case:

1

? ? ? ? 300

will fail your code. There is only one correct answer:

100 100 0 0 300

tankibudson Apr 13, 2017 - 1:19:40 am UTC Re: Test data wrong?Miminyte500on Jan 18, 2015 - 4:15:36 pm UTC The amount of hidden information