The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it.

The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "*x* bulls *y* cows". *x* represents the number of digits in the experimental number that occupy the same positions as in the sought number. *y* represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present.

For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). 

When the guesser is answered "4 bulls 0 cows", the game is over.

Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one.
The first input line contains an integer *n* (1 ≤ *n* ≤ 10) which represents the number of already made guesses. Then follow *n* lines in the form of "*a*<sub class="lower-index">*i*</sub> *b*<sub class="lower-index">*i*</sub> *c*<sub class="lower-index">*i*</sub>", where *a*<sub class="lower-index">*i*</sub> is the *i*-th experimental number, *b*<sub class="lower-index">*i*</sub> is the number of bulls, *c*<sub class="lower-index">*i*</sub> is the number of cows (1 ≤ *i* ≤ *n*, 0 ≤ *b*<sub class="lower-index">*i*</sub>, *c*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> + *c*<sub class="lower-index">*i*</sub> ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present.
none
2
1263 1 2
8103 2 1
Need more data
2
1234 2 2
1256 0 2
2134
2
0123 1 1
4567 1 2
Incorrect data
1
1234 0 0
Need more data
4
4789 1 0
7189 1 0
7829 1 0
7893 1 0
4123
4
1789 1 0
7198 1 0
9817 1 0
8971 1 0
Incorrect data
6
1234 3 0
1235 3 0
1236 3 0
1237 3 0
1238 3 0
1239 3 0
1230
3
0123 0 4
1230 0 4
3012 0 4
2301
1
0714 1 1
Need more data
2
0159 1 0
0153 1 0
Need more data
3
9703 3 0
0925 0 2
3059 0 3
Need more data
4
1689 0 1
0159 0 2
4326 0 1
9048 0 2
Need more data
5
9084 1 0
4615 0 1
0826 0 2
1275 0 3
5631 0 1
Need more data
6
1586 0 2
6105 1 1
5382 0 1
8164 0 2
0647 0 1
6059 1 1
Need more data
7
7401 0 2
1524 0 0
1495 0 0
9230 0 2
9874 1 0
9574 1 0
4693 1 1
6073
8
7954 0 1
5638 0 1
8204 0 2
8293 1 1
3598 0 1
0894 0 1
6324 1 2
0572 0 1
Need more data
9
8742 0 1
5183 1 1
6149 1 0
3568 0 2
9258 1 2
5193 1 2
7403 0 1
9124 0 2
3058 0 2
5239
10
7098 2 1
7693 1 1
6428 0 2
5209 0 2
1683 0 2
0432 0 1
5697 1 1
2437 0 0
4593 1 0
1784 0 1
8096
10
8795 0 3
4971 1 1
5032 0 1
5479 0 3
2501 0 1
9052 1 0
3649 0 1
1927 1 0
9173 0 1
8014 0 2
4857
10
0459 2 0
2371 0 1
5209 2 1
1306 0 0
0213 1 0
4173 0 0
5076 0 1
9674 0 1
2894 0 3
3527 0 2
8259
10
0132 0 1
6801 0 1
8749 1 1
8036 0 0
7384 0 2
8594 1 1
9307 1 0
7390 0 1
6127 1 1
0381 0 1
1547
10
9360 0 1
5208 0 2
7861 1 0
8916 0 1
5937 1 1
7082 0 1
3402 0 2
7230 1 0
1794 0 1
8293 0 2
4835
2
3794 2 2
8647 0 4
Incorrect data
2
9726 3 1
6583 1 1
Incorrect data
3
6093 3 0
7902 2 0
2305 2 1
Incorrect data
3
6108 0 3
4975 1 1
0981 1 2
Incorrect data
4
7153 2 1
5810 1 0
8439 0 2
2794 1 3
Incorrect data
4
4259 1 3
1985 0 3
5263 2 2
5703 3 1
Incorrect data
5
9784 3 0
2657 0 3
7536 1 0
0762 1 3
2014 1 1
Incorrect data
5
2746 0 3
1509 3 0
4135 2 0
7536 0 4
1825 3 0
Incorrect data
6
5132 1 0
3085 3 0
0523 1 3
6912 3 0
7406 2 1
3179 2 1
Incorrect data
6
1034 3 0
0514 2 2
1092 2 2
0814 0 4
9182 2 0
9534 0 0
Incorrect data
7
9230 3 1
7401 3 1
6073 0 0
1495 0 0
9574 2 0
4693 2 2
1524 1 2
Incorrect data
4
0789 1 0
7189 1 0
7829 1 0
7893 1 0
0123
1
1234 3 1
Incorrect data
2
1234 0 0
5678 0 0
Incorrect data
2
1340 0 0
2435 0 0
Need more data
3
1024 0 1
5678 3 0
1542 0 0
0678
3
1234 0 4
2413 0 4
4123 0 4
Incorrect data
5
0123 0 1
4567 0 1
8901 0 1
6789 0 1
2345 0 1
Incorrect data
1
1234 2 2
Need more data
2
1234 2 2
2134 2 2
Incorrect data
3
6789 0 2
1234 0 2
3467 0 0
Need more data
3
6789 0 2
1234 2 0
3467 0 0
1298
4
0123 1 0
0342 1 0
5678 2 0
2981 0 1
0679
3
1234 3 0
5678 0 0
1239 3 0
1230
6
3102 3 0
4102 3 0
5102 3 0
6102 3 0
7102 3 0
8102 3 0
9102
4
0123 1 3
3012 1 3
2301 2 2
1230 0 4
Incorrect data
10
0231 2 2
3021 2 2
2301 2 2
0451 2 2
5041 2 2
4501 2 2
0671 2 2
7061 2 2
8901 2 2
0891 2 2
Incorrect data
8
1023 2 2
1032 2 2
1045 2 2
1054 2 2
1067 2 2
1076 2 2
1089 2 2
1098 2 2
Incorrect data
2
5678 1 3
5432 1 3
Incorrect data
2
2034 2 2
2056 0 2
0234
6
0132 2 2
0321 2 2
3120 2 2
0213 2 2
2103 2 2
1023 2 2
0123
3
0235 3 0
0236 3 0
7894 1 0
0234
2
1234 0 0
5678 0 0
Incorrect data
2
1234 3 1
1253 3 1
Incorrect data
5
3210 0 4
0789 1 0
7189 1 0
7829 1 0
7893 1 0
0123
2
1234 3 1
1253 3 1
Incorrect data
2
1234 0 0
5678 0 0
Incorrect data
#! /usr/bin/python3
import sys
import pprint

def main():
    input_list = []
    for line in sys.stdin:
        input_list.append(line.rstrip("\n"))
        """
        # DEBUG
        if line.rstrip("\n") == "exit":
            break
        """
    possible_nums = ["{0:04}".format(i) for i in range(123, 10000)] # List of all possible 4 digit numbers as strings form "0123" to "9999"

    for i in range(int(input_list[0])):
        check_list = input_list[i + 1].split(" ")
        possible_nums = filter(possible_nums, check_list[0], check_list[1], check_list[2])
        """
        # DEBUG
        print(possible_nums)
        """
    if len(possible_nums) == 0:
        print("Incorrect data")
    elif len(possible_nums) == 1:
        print(possible_nums[0])
    else:
        print("Need more data")
    
def check_cow(input_num, check_num, cow):
    cow_num = 0
    union_set = set(ordered_union(list(input_num), list(check_num))) # Set of Strings
    cow_num = len((set(input_num) - union_set).intersection(set(check_num) - union_set))

    return cow_num == cow

def check_bull(input_num, check_num, bull):
    bull_num = 0
    bull_num = len(ordered_union(list(input_num), list(check_num)))

    return bull_num == bull

def filter(possible_nums, input_num, bull, cow):
    filtered_list = []

    for num in possible_nums:
        if check_cow(input_num, num, int(cow)) and check_bull(input_num, num, int(bull)) and not has_repeat(num):
            filtered_list.append(num)

    return filtered_list

def ordered_union(list1, list2):
    union_list = []

    for i in range(len(list1)):
        if list1[i] == list2[i]:
            union_list.append(list1[i])
    return union_list

def has_repeat(num):
    return len(set(num)) != len(num)

if __name__ == "__main__":
    main()
