Start: Jan, 29, 2016 12:00:00
2016年1月寒假集训训练赛Round#5
End: Jan, 29, 2016 17:00:00
Time elapsed:
Time remaining:

Number Guessing 1463

Time Limit:  1 s      Memory Limit:   32 MB
Submission:41     AC:9     Score:1

Description

Number Guessing is a computer game. First, the computer chooses four different digits, you need to guess these four digits in the fewest times,for each guess, the computer will show a judgement in the form of "#A#B", "#" is a number 0~4. "#A" shows how many digits you guessed with both correct value and position. "#B" shows how many digits you guessed with correct value. For example, the computer chose 1234, and you guessed 6139, the computer will show "1A2B" for you have number "1" correct value but wrong position and number "3" correct value with correct position.Thus the computer gives you the judgement of "1A2B"

Now you have memorized the digits you guessed and the judgements you got, you feel like you can figure out the correct answer. Life is filled with wisdom, isn't it?

Input

There are several test cases. For each test case, the first line contains a single positive integer N indicates the times you can guess,the following N lines is the record of the guess, in the form:

#### #A#B

The first four numbers is the numbers guessed, then the judgements for your guess.

The input terminated when N is not postive integer, and not need to proceed.

Output

For each test case, output a single line contains exactly four digits that the computer has chosen. You may assume that each test case gives you enough information, so you can figure out the correct answer.

Samples

input
2 1234 2A4B 1243 0A4B 3 0732 3A3B 1526 0A0B 4567 0A2B -1
output
2134 0734