Task
A ranking line of the form — (matches, victories, draws, defeats, points) is given, where some of the values may be denoted with a question mark () but not . This ranking line corresponds to the results of a team throughout a competitive season in a football league in Southeast Europe.
Now B.B.C, a specialist in the field, wants to know if we can obtain a configuration starting from the current configuration that is valid according to football rules ( points for a victory, point for a draw, points for defeats), or if it is impossible. This can be done by replacing the question marks with natural numbers.
For example, the configuration is valid because we can obtain the configuration — victories, draw, and defeat.
Note that the number of matches is always known.
Input data
The first line will contain the number of tests .
Each of the next lines will contain a configuration in the format described in the statement, each of the positions can contain either the character ?
or a natural number, representing the corresponding number for that position.
Output data
Each line will contain either a valid configuration starting from the given input configuration or the message Impossible
if it is not possible.
Any valid configuration is accepted.
Constraints and clarifications
# | Score | Constraints |
---|---|---|
1 | 0 | Example |
2 | 13 | Only one variable is unknown and |
3 | 13 | The number of points is always unknown and |
4 | 20 | |
5 | 13 | Only one variable is unknown |
6 | 13 | The number of points is always unknown |
7 | 28 | No additional constraints |
Example
stdin
17
5 ? ? ? ?
9 4 ? 4 ?
7 ? ? 5 4
4 1 2 1 6
6 3 ? 4 12
9 ? 4 ? 13
14 5 ? ? 13
58 28 ? ? 94
100 ? ? 43 120
10 ? ? ? ?
10 4 3 3 ?
10 4 3 ? ?
10 4 ? 3 ?
10 4 ? ? ?
10 ? 3 3 ?
10 ? 3 ? ?
10 ? ? 3 ?
stdout
5 0 0 5 0
9 4 1 4 13
7 1 1 5 4
Impossible
Impossible
9 3 4 2 13
Impossible
58 28 10 20 94
Impossible
10 0 0 10 0
10 4 3 3 15
10 4 3 3 15
10 4 3 3 15
10 4 0 6 12
10 4 3 3 15
10 0 3 7 3
10 0 7 3 7