MisLED

Time limit1sMemory limit128 MB

Problem

Rocky rolled over in bed and glanced at his LED alarm clock. He saw the time and drifted back to sleep. Later he woke again and glanced at the clock once more. Even though he could not tell which of the LED segments were still working, he was able to determine the exact time with certainty. Can you?

Rocky's LED clock shows the time with four 7-segment displays.

Each 7-segment display has seven bars and forms different digits by lighting different bars:

 _       _  _       _   _   _   _   _
| |   |  _| _| |_| |_  |_    | |_| |_|
|_|   | |_  _|   |  _| |_|   | |_|  _|

We can describe one display with seven bits, one bit per segment. Suppose the segments are numbered like this:

Then the display

|_
| 

is written with the bits

0000111

so the ten digits can be written as:

NumberBit 1Bit 2Bit 3Bit 4Bit 5Bit 6Bit 7
01111110
10110000
21101101
31111001
40110011
51011011
61011111
71110000
81111111
91111011

If a segment is "burnt out", it never lights even when it should. For example, if the digit 3 should be shown but the segment for bit 7 is burnt out, the display looks like this instead:

 _ 
  |
 _|

Input

The first line contains a single integer $n$, the number of data sets.

Each data set is one line of eight 7-bit strings describing the observed displays. The first four strings are the four displays of the first observed time, and the next four strings are the four displays of the second observed time. All strings are separated by single spaces. Which segments are burnt out is not given in the input.

Output

For each data set, print exactly one line: the second observed time, in the format H:MM.

The burnt-out segments are the same for the first and the second observation. Every data set has exactly one possible answer.

Times use the standard (12-hour) format with no leading zero on the hour (nine o'clock is written 9:00, not 09:00), while the minutes always have two digits.