#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-10;
template <typename T, typename S>
vector<T>& operator<<(vector<T>& a, S b) {
  a.push_back(b);
  return a;
}
template <typename T>
void operator>>(vector<T>& a, int b) {
  while (b--)
    if (!a.empty()) a.pop_back();
}
bool isprime(int n) {
  if (n < 2) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long b_pow(long long x, long long n) {
  return n ? n == 1 ? x : b_pow(x, n >> 1) * b_pow(x, (n >> 1) + (n & 1)) : 1;
}
string itos(int n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
bool iscorrect(string a, string b, int hit, int blow) {
  int one = 0, two = 0;
  for (int i = 0; i < a.size(); i++) {
    for (int j = 0; j < b.size(); j++) {
      if (a[i] == b[j]) {
        if (i == j)
          one++;
        else
          two++;
      }
    }
  }
  return one == hit && blow == two;
}
int main() {
  int n;
  cin >> n;
  vector<string> one(n);
  vector<int> hit(n), blow(n);
  vector<string> get;
  for (int i = 0; i < n; i++) {
    cin >> one[i] >> hit[i] >> blow[i];
  }
  for (int i = 0; i < (1 << 10); i++) {
    if (__builtin_popcount(i) != 4) continue;
    string t = "";
    for (int j = 0; j < 10; j++) {
      if ((1 << j) & (i)) {
        t += '0' + j;
      }
    }
    do {
      get.push_back(t);
    } while (next_permutation(t.begin(), t.end()));
  }
  int r = 0;
  string ans;
  for (int i = 0; i < get.size(); i++) {
    bool able = 1;
    for (int j = 0; j < n; j++) {
      able &= iscorrect(get[i], one[j], hit[j], blow[j]);
    }
    if (able) {
      r++;
      ans = get[i];
    }
  }
  if (r > 1)
    cout << "Need more data" << endl;
  else if (r < 1)
    cout << "Incorrect data" << endl;
  else
    cout << ans << endl;
}
