#include <bits/stdc++.h>
using namespace std;
int getLen(int l) { return l / 10 == 0 ? 1 : l / 100 == 0 ? 2 : 3; }
int main() {
  int n, k, S = 0;
  bool b = false;
  cin >> n;
  int **arr = new int *[n];
  for (int i = 0; i < n; i++) {
    arr[i] = new int[9];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 9; j++) {
      arr[i][j] = -1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> k;
      arr[i][k] = k;
    }
  }
  for (int i = 1; i <= 999; i++) {
    switch (getLen(i)) {
      case 1:
        for (int j = 0; j < n; j++) {
          if (arr[j][i] == i) {
            S++;
            b = true;
            break;
          }
        }
        break;
      case 2:
        for (int j = 0; j < n; j++) {
          if (arr[j][i / 10] != i / 10) continue;
          for (int k = 0; k < n; k++) {
            if (arr[j][i / 10] * 10 + arr[k][i % 10] == i && j != k) {
              S++;
              b = true;
              break;
            }
          }
          if (b) break;
        }
        break;
      case 3:
        for (int j = 0; j < n; j++) {
          if (arr[j][i / 100] != i / 100) continue;
          for (int k = 0; k < n; k++) {
            if (arr[j][i / 10] != i / 10 || k == j) continue;
            for (int p = 0; p < n; p++) {
              if (k == p || p == j) continue;
              if (arr[j][i / 100] * 100 + arr[j][i / 10 % 10] * 10 +
                      arr[j][i % 10] ==
                  i / 10 % 10) {
                S++;
                b = true;
                break;
              }
            }
            if (b) break;
          }
          if (b) break;
        }
        break;
    }
    if (!b) {
      cout << S;
      return 0;
    }
    b = false;
  }
  return 0;
}
