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.

Input

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 "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 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.

Output

If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes.

Examples

Input

2
1263 1 2
8103 2 1


Output

Need more data

Input

2
1234 2 2
1256 0 2


Output

2134

Input

2
0123 1 1
4567 1 2


Output

Incorrect data
import java.util.*;


import java.awt.Checkbox;
import java.io.*;

public class C {
	static ArrayList<Integer> primes;
	static int[] isComposite;
	static int[] idx;
	static int[] p;

	static void sieve(int N) // O(N log log N)
	{
		isComposite = new int[N + 1];
		idx = new int[N + 1];
		isComposite[0] = isComposite[1] = 1; // 0 indicates a prime number
		primes = new ArrayList<Integer>();

		int ix = 1;
		for (int i = 2; i <= N; ++i) // can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) // can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				idx[i] = ix;
				ix++;
				if (1l * i * i <= N)
					for (int j = i * i; j <= N; j += i) // j = i * 2 will not affect performance too much, may alter in
														// modified sieve
						isComposite[j] = 1;
			}
		p = new int[primes.size()];
		int i = 0;
		for (int x : primes) {
			p[i++] = x;
		}
	}

	static long pow(long a, long e) // O(log e)
	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res *= a;
			a *= a;
			e >>= 1;
		}
		return res;
	}

	static int[] cum;
	static int n;
	static int m;
	static int x;
	static int y;
	static int[][][] memo;

	static int dp(int idx, int l, int s) {
		if (idx == m)
			return 0;
		if (memo[s][idx][l] != -1)
			return memo[s][idx][l];
		int t = 1000000000;
		int le = 1000000000;
		if (s == 0) {
			if (l != y)
				t = cum[idx + 1] - cum[idx] + dp(idx + 1, l + 1, s);
			if (idx + x <= m)
				le = x * n - (cum[idx + x] - cum[idx]) + dp(idx + x, x, 1);
		} else {
			if (l != y)
				t = n - cum[idx + 1] + cum[idx] + dp(idx + 1, l + 1, s);
			if (idx + x <= m)
				le = cum[idx + x] - cum[idx] + dp(idx + x, x, 0);
		}
		return memo[s][idx][l] = Math.min(t, le);
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int n = Integer.parseInt(br.readLine());

		pair2[] a = new pair2[n];
		for (int i = 0; i < a.length; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			a[i] = new pair2(st.nextToken().toCharArray(), Integer.parseInt(st.nextToken()),
					Integer.parseInt(st.nextToken()));
		}
		arr = new ArrayList<>();
		for (int i = 100; i < 10000; i++) {
			check(i);
		}
//		System.out.println(Arrays.toString(arr.get(0)));
		boolean[] vis = new boolean[arr.size()];
		for (int i = 0; i < vis.length; i++) {
			boolean f = true;
			int[] t = arr.get(i);
			for (int j = 0; j < n && f; j++) {
				if (check(t, a[j].x, a[j].y, a[j].idx))
					;
				else
					f = false;
			}
			if (f)
				vis[i] = true;
		}
		int c = 0;
		int[] ans = new int[4];
		for (int i = 0; i < vis.length; i++) {
			if (vis[i]) {
				c++;
				ans = arr.get(i);
			}
		}
//		System.out.println(check(new int[] {2,1,3,4}, new char[] {'1','2','5','6'}, 0, 2));
		if (c == 1)
			for (int i = 0; i < ans.length; i++) {
				pw.print(ans[i]);
			}
		else if (c > 1)
			pw.println("Need more data");
		else
			pw.println("Incorrect data");
		pw.flush();

	}

	static boolean[] vis;
	static ArrayList<pair1>[] a;
	static ArrayList<int[]> arr;

	static boolean check(int x) {
		char[] a = (x + "").toCharArray();
		int[] b = new int[4];
		int i = a.length - 1;
		for (int j = 3; i >= 0; j--, i--) {
			b[j] = a[i] - '0';
		}
		HashSet<Integer> h = new HashSet<>();
		for (int j = 0; j < b.length; j++) {
			if (h.contains(b[j]))
				return false;
			h.add(b[j]);
		}
		arr.add(b);
		return true;
	}

	static boolean check(int[] x, char[] y, int b, int c) {
		int b1 = 0;
		HashSet<Integer> h = new HashSet<>();
		for (int i = 0; i < y.length; i++) {
			if (x[i] == y[i] - '0')
				b1++;
			else
				h.add(x[i]);
		}
		int c1 = 0;
		for (int i = 0; i < y.length; i++) {
			if (h.contains(y[i]-'0'))
				c1++;
		}
//		System.out.println(b1+" "+c1);
		return b == b1 && c == c1;
	}

	static class SegmentTree { // 1-based DS, OOP

		int N; // the number of elements in the array as a power of 2 (i.e. after padding)
		int[] array, sTree, lazy;

		SegmentTree(int[] in) {
			array = in;
			N = in.length - 1;
			sTree = new int[N << 1]; // no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new int[N << 1];
			build(1, 1, N);
		}

		void build(int node, int b, int e) // O(n)
		{
			if (b == e)
				sTree[node] = array[b];
			else {
				int mid = b + e >> 1;
				build(node << 1, b, mid);
				build(node << 1 | 1, mid + 1, e);
				sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
			}
		}

		void update_point(int index, int val) // O(log n)
		{
			index += N - 1;
			sTree[index] += val;
			while (index > 1) {
				index >>= 1;
				sTree[index] = sTree[index << 1] + sTree[index << 1 | 1];
			}
		}

		void update_range(int i, int j, int val) // O(log n)
		{
			update_range(1, 1, N, i, j, val);
		}

		void update_range(int node, int b, int e, int i, int j, int val) {
			if (i > e || j < b)
				return;
			if (b >= i && e <= j) {
				sTree[node] += (e - b + 1) * val;
				lazy[node] += val;
			} else {
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node << 1, b, mid, i, j, val);
				update_range(node << 1 | 1, mid + 1, e, i, j, val);
				sTree[node] = sTree[node << 1] + sTree[node << 1 | 1];
			}

		}

		void propagate(int node, int b, int mid, int e) {
			lazy[node << 1] += lazy[node];
			lazy[node << 1 | 1] += lazy[node];
			sTree[node << 1] += (mid - b + 1) * lazy[node];
			sTree[node << 1 | 1] += (e - mid) * lazy[node];
			lazy[node] = 0;
		}

		int query(int i, int j) {
			return query(1, 1, N, i, j);
		}

		int query(int node, int b, int e, int i, int j) // O(log n)
		{
			if (i > e || j < b)
				return 0;
			if (b >= i && e <= j)
				return sTree[node];
			int mid = b + e >> 1;
			propagate(node, b, mid, e);
			int q1 = query(node << 1, b, mid, i, j);
			int q2 = query(node << 1 | 1, mid + 1, e, i, j);
			return q1 + q2;

		}

	}

	static int power(int x, int y) {
		int res = 1; // Initialize result
		x = x; // Update x if it is more
				// than or equal to p
		while (y > 0) {
			// If y is odd, multiply
			// x with result
			if ((y & 1) > 0)
				res = (res * x);

			// y must be even now
			y = y >> 1; // y = y/2
			x = (x * x);
		}
		return res;
	}

	static int sum(long n) {
		int c = 0;
		while (n != 0) {
			c += n % 10;
			n /= 10;
		}
		return c;
	}

	static int g_div(int x) {
		for (int i = 2; i * i <= x; i++)
			if (x % i == 0)
				return x / i;
		return 1;
	}

	static int gcd(int a, int b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;
		int z;
		int idx;

		public pair(int d, int u, int w, int in) {
			x = d;
			y = u;
			z = w;
			idx = in;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return z - o.z;
		}

	}

	static class pair2 implements Comparable<pair2> {
		char[] x;
		int y;
		int idx;

		public pair2(char[] d, int u, int in) {
			x = d;
			y = u;
			idx = in;
		}

		@Override
		public int compareTo(pair2 o) {
			// TODO Auto-generated method stub
			return y - o.y;

		}

	}

	static class pair1 implements Comparable<pair1> {
		int x;
		int idx;

		public pair1(int d, int w) {
			x = d;
			idx = w;
		}

		@Override
		public int compareTo(pair1 o) {
			// TODO Auto-generated method stub

			return x - o.x;
		}

	}

}
