#P6458. Complete the Tournament Statistics

    ID: 19672 Type: Default 1000ms 256MiB

Complete the Tournament Statistics

Complete the Tournament Statistics

There are n teams competing in a tournament. Each team has five parameters: total matches played, wins, draws, losses, and score. For each win, 3 points are awarded; for each draw, 1 point is given; losses score 0 points. Due to damage in the record, some entries are obscured and are represented by a question mark ('?'). Your task is to deduce and fill in these missing values based on the following two equations:

[ \text{Total} = \text{Wins} + \text{Draws} + \text{Losses} ]

[ \text{Score} = 3 \times \text{Wins} + \text{Draws} ]

It is guaranteed that every missing entry can be uniquely determined from the other data, and that each team has played at most 100 matches. Note that you can treat each team as an independent entity.

inputFormat

The first line contains an integer n indicating the number of teams. Each of the following n lines contains five tokens separated by spaces representing total matches, wins, draws, losses, and score, respectively. If a value is missing, it is represented by a question mark ('?').

outputFormat

For each team, output the complete statistics as five space-separated integers in the order: total matches, wins, draws, losses, score.

sample

3
? 3 1 1 10
5 ? 1 1 10
5 0 ? 5 ?
5 3 1 1 10

5 3 1 1 10 5 0 0 5 0

</p>