#include <bits/stdc++.h>
using namespace std;
int vis[4][11];
int main() {
  int n, tmp;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 6; j++) {
      cin >> tmp;
      vis[i][tmp]++;
    }
  }
  if (n == 1) {
    for (int i = 1; i <= 9; i++) {
      if (vis[1][i])
        continue;
      else {
        cout << i - 1 << endl;
        return 0;
      }
    }
  } else if (n == 2) {
    for (int i = 1; i <= 9; i++) {
      if (vis[1][i] || vis[2][i])
        continue;
      else {
        cout << i - 1 << endl;
        return 0;
      }
    }
    for (int i = 10; i <= 99; i++) {
      int t1 = i / 10, t2 = i % 10;
      if ((vis[1][t1] && vis[2][t2]) || (vis[1][t2] && vis[2][t1]))
        continue;
      else {
        cout << i - 1 << endl;
        return 0;
      }
    }
  } else if (n == 3) {
    for (int i = 1; i <= 9; i++) {
      if (vis[1][i] || vis[2][i] || vis[3][i])
        continue;
      else {
        cout << i - 1 << endl;
        return 0;
      }
    }
    for (int i = 10; i <= 99; i++) {
      int t1 = i / 10, t2 = i % 10;
      if ((vis[1][t1] && vis[2][t2]) || (vis[1][t2] && vis[2][t1]) ||
          (vis[1][t1] && vis[3][t2]) || (vis[3][t1] && vis[1][t2]) ||
          (vis[2][t1] && vis[3][t2]) || (vis[3][t1] && vis[2][t2]))
        continue;
      else {
        cout << i - 1 << endl;
        return 0;
      }
    }
    for (int i = 100; i <= 999; i++) {
      int t1 = i / 100, t2 = (i / 10) % 10, t3 = i % 10;
      if ((vis[1][t1] && vis[2][t2] && vis[3][t3]) ||
          (vis[1][t1] && vis[3][t2] && vis[2][t3]) ||
          (vis[2][t1] && vis[1][t2] && vis[3][t3]) ||
          (vis[2][t1] && vis[3][t2] && vis[1][t3]) ||
          (vis[3][t1] && vis[1][t2] && vis[2][t3]) ||
          (vis[3][t1] && vis[2][t2] && vis[1][t3]))
        continue;
      else {
        cout << i - 1 << endl;
        return 0;
      }
    }
  }
  return 0;
}
