Guess The Number

Time Limit: 5 Seconds    Memory Limit: 32768 KB

Everyone knows how to play the game of Guess The Number, which goes like this:

One of the player one conceives a secret number, while another player makes several guesses. In each guess, the first player would tell how many digits are right in the specific position and how many digits are right but not in their position. For example, the secret number is "7047" and the guess is "7474". We have a "7" in the right position (the most significant digit) and another "4" and "7" that are right but not in position. So the second player would be told 1 2.

In our problem, all the numbers are of 6 digits from 000000 to 999999. Leading zeros are allowed.

Input

This problem contains multiple tests. Each test starts with a positive integer N, followed by N lines in the format Guess A B. Guess is a six digit number. A and B are the reply of the first player. A test with N = 0 indicates the end of input, and this test is not to be processed.

Output

One conclusion for each test on a single line. The possibilities are:

> The answer NUMBER was found after all tries.

> The answer NUMBER was found after T tries.

> No such number.

> Still can't decide.

NUMBER is a six digit number. T is an integer ( T < N ). Always use "tries" even if T = 1.

Sample Input

2
111112 4 2
111121 6 0
2
111111 5 0
222222 5 0
0

Sample Output

The answer 111121 was found after all tries.
No such number.
Submit

Source: ZOJ Monthly, December 2002