#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[3][7], a1[100] = {0};
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> a[i][j];
      a1[a[i][j]] = 1;
    }
  }
  if (n == 3) {
    for (int j = 0; j < 6; j++) {
      for (int k = 0; k < 6; k++) {
        a1[a[0][j] * 10 + a[1][k]] = a1[a[0][j] * 10 + a[2][k]] = 1;
        a1[a[1][j] * 10 + a[0][k]] = a1[a[1][j] * 10 + a[2][k]] = 1;
        a1[a[2][j] * 10 + a[1][k]] = a1[a[2][j] * 10 + a[0][k]] = 1;
      }
    }
  } else if (n == 2) {
    for (int j = 0; j < 6; j++) {
      for (int k = 0; k < 6; k++) {
        a1[a[0][j] * 10 + a[1][k]] = 1;
        a1[a[1][j] * 10 + a[0][k]] = 1;
      }
    }
  }
  int f = 0;
  for (int i = 1; i < 100; i++) {
    if (a1[i])
      f = i;
    else {
      cout << f << endl;
      break;
    }
  }
  return 0;
}
