#include <bits/stdc++.h>
using namespace std;
set<string> sx;
vector<string> vx;
int ft;
void generate(char str[], int k, int l) {
  if (k < 0) {
    str[l] = '\0';
    bool status = true;
    for (int i = 0; i < strlen(str); i++) {
      for (int j = i + 1; j < strlen(str); j++) {
        if (str[i] == str[j]) {
          status = false;
          break;
        }
      }
      if (status == false) break;
    }
    if (status) {
      vx.push_back(string(str));
    }
    return;
  } else {
    for (int i = 0; i <= 9; i++) {
      str[l] = i + '0';
      generate(str, k - 1, l + 1);
    }
  }
}
set<string> check(string sno, int a, int b, set<string> fx) {
  set<string> px;
  for (int i = 0; i < vx.size(); i++) {
    int c = 0, d = 0;
    for (int j = 0; j < 4; j++) {
      if (vx[i][j] == sno[j])
        c++;
      else {
        for (int k = 0; k < 4; k++)
          if (vx[i][j] == sno[k]) {
            d++;
            break;
          }
      }
    }
    if (c == a && b == d) {
      if (ft == 0 || fx.find(vx[i]) != fx.end()) px.insert(vx[i]);
    }
  }
  ft = 1;
  return px;
}
int main() {
  char str[10];
  generate(str, 3, 0);
  set<string> fx;
  ft = 0;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    char inp[100];
    getchar();
    scanf("%[^\n]", inp);
    string sno = "";
    int b, c;
    b = c = -1;
    bool stat = false;
    for (int i = 0; i < strlen(inp); i++) {
      if (inp[i] == ' ')
        stat = true;
      else {
        if (!stat)
          sno += inp[i];
        else if (b == -1)
          b = inp[i] - '0';
        else if (c == -1)
          c = inp[i] - '0';
      }
    }
    fx = check(sno, b, c, fx);
  }
  if (fx.size() == 1) {
    string req = *(fx.begin());
    cout << req << endl;
  } else if (fx.size() > 1)
    cout << "Need more data" << endl;
  else if (fx.size() == 0)
    cout << "Incorrect data" << endl;
  return 0;
}
