Championship in Basketball

Time Limit:1000ms Memory Limit:64000KiB
Accepted:0 Submitted:0
Championship in Basketball

BOI 98 Day 1 Problem 3

Championship in Basketball

Here you have the result from BSCB (Baltic Sea Championship in Basketball). As you can see the team from Lithuania won the victory, winning all four games. The team from Sweden made a bad tournament and was beaten in all games.

LIT 4 0 344 - 267
LAT 3 1 368 - 287
EST 2 2 396 - 397
FIN 1 3 414 - 473
SWE 0 4 267 - 365

You read the table in this way:

Column Explanation
1 The name of the team (always the same and in the same order and never used in problem).
2 The number of won games.
3 The number of lost games.
4 The number of made points.
5 The number of lost points.

Your program will be given the table and 20 matchpoints (i.e. points collected by each team in each game) Pi (1<=Pi<=200, all different). Then it will have to find the unique results of every game for filling a table like this:

 

LIT

LAT

EST

FIN

SWE

LIT

-

48

106

120

70

LAT

41

-

111

137

79

EST

102

89

-

123

82

FIN

66

97

117

-

134

SWE

58

53

63

93

-

For instance, the match LAT - SWE closed 79 - 53.

Input

There are at first five rows in input file MATCH.IN, with four numbers in each (compare with the table given above).

And then in a single line, the 20 matchpoints in some order.

The teams in input table are not necessarily ranked by final result.

Output

In the output file MATCH.OUT must be the gameschedule without text, written with at least one blank between numbers.

Use zero (0) in stead of -. Remember that in the testcases there is always a unique solution.

Sample Input

4 0 344 267
3 1 368 287
2 2 396 397
1 3 414 473
0 4 267 365
41 48 53 58 63 66 70 79 82 89 93 97 102 106 111 117 120 123 134 137

Sample Output

0 48 106 120 70
41 0 111 137 79
102 89 0 123 82
66 97 117 0 134
58 53 63 93 0

Remark

Timelimit: 2 min
SubmitStatistics

SOJ is designed and developed by Wilbur Ding and Liang Sun. ©All Rights Reserved 2009-2012.