#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1000 + 10;
const int mod = 1e9 + 7;
int a[3][6];
int vis[100];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 6; j++) cin >> a[i][j];
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < 6; k++) {
      vis[a[i][k]] = 1;
      for (int j = 0; j < n; j++) {
        if (i == j) continue;
        for (int l = 0; l < 6; l++) {
          vis[a[i][k] * 10 + a[j][l]] = 1;
        }
      }
    }
  }
  for (int i = 1; i < 100; i++) {
    if (!vis[i]) {
      cout << i - 1 << endl;
      break;
    }
  }
}
