#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> v[3];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      long long x;
      cin >> x;
      v[i].push_back(x);
    }
  }
  long long p = 0;
  if (n == 1) {
    for (int i = 1; i <= 9; i++) {
      vector<long long>::iterator it;
      it = find(v[0].begin(), v[0].end(), i);
      if (it == v[0].end()) {
        break;
      }
      p = i;
    }
  } else if (n == 2) {
    for (int i = 1; i <= 99; i++) {
      if (i < 10) {
        vector<long long>::iterator it, pt;
        it = find(v[0].begin(), v[0].end(), i);
        pt = find(v[1].begin(), v[1].end(), i);
        if (it == v[0].end() && pt == v[1].end()) {
          break;
        }
      } else {
        vector<long long>::iterator it, pt;
        it = it = find(v[0].begin(), v[0].end(), i / 10);
        pt = find(v[1].begin(), v[1].end(), i % 10);
        if (it == v[0].end() || pt == v[1].end()) {
          it = find(v[0].begin(), v[0].end(), i % 10);
          pt = find(v[1].begin(), v[1].end(), i / 10);
          if (it == v[0].end() || pt == v[1].end()) {
            break;
          }
        }
      }
      p = i;
    }
  } else {
    for (int i = 1; i <= 999; i++) {
      if (i < 10) {
        vector<long long>::iterator it;
        it = find(v[0].begin(), v[0].end(), i);
        if (it == v[0].end()) {
          it = find(v[1].begin(), v[1].end(), i);
          if (it == v[1].end()) {
            it = find(v[2].begin(), v[2].end(), i);
            if (it == v[2].end()) {
              break;
            }
          }
        }
      } else if (i < 100) {
        vector<long long>::iterator it, pt, st;
        it = find(v[0].begin(), v[0].end(), i / 10);
        pt = find(v[1].begin(), v[1].end(), i / 10);
        st = find(v[2].begin(), v[2].end(), i / 10);
        int l = 0;
        if (it != v[0].end()) {
          vector<long long>::iterator it1, it2;
          it1 = find(v[1].begin(), v[1].end(), i % 10);
          it2 = find(v[2].begin(), v[2].end(), i % 10);
          if (it1 != v[1].end() || it2 != v[2].end()) {
            l = 1;
          }
        }
        if (pt != v[1].end()) {
          vector<long long>::iterator it1, it2;
          it1 = find(v[0].begin(), v[0].end(), i % 10);
          it2 = find(v[2].begin(), v[2].end(), i % 10);
          if (it1 != v[0].end() || it2 != v[2].end()) {
            l = 1;
          }
        }
        if (st != v[2].end()) {
          vector<long long>::iterator it1, it2;
          it1 = find(v[1].begin(), v[1].end(), i % 10);
          it2 = find(v[0].begin(), v[0].end(), i % 10);
          if (it1 != v[1].end() || it2 != v[0].end()) {
            l = 1;
          }
        }
        if (l == 0) break;
      } else {
        vector<long long>::iterator it, pt, st;
        it = find(v[0].begin(), v[0].end(), i / 100);
        pt = find(v[1].begin(), v[1].end(), i / 100);
        st = find(v[2].begin(), v[2].end(), i / 100);
        int l = 0;
        if (it != v[0].end()) {
          vector<long long>::iterator it1, it2;
          it1 = find(v[1].begin(), v[1].end(), i % 10);
          it2 = find(v[2].begin(), v[2].end(), i / 10);
          if (it1 != v[1].end() && it2 != v[2].end()) {
            l = 1;
          }
          it1 = find(v[1].begin(), v[1].end(), i / 10);
          it2 = find(v[2].begin(), v[2].end(), i % 10);
          if (it1 != v[1].end() && it2 != v[2].end()) {
            l = 1;
          }
        }
        if (pt != v[1].end()) {
          vector<long long>::iterator it1, it2;
          it1 = find(v[0].begin(), v[0].end(), i % 10);
          it2 = find(v[2].begin(), v[2].end(), i / 10);
          if (it1 != v[0].end() && it2 != v[2].end()) {
            l = 1;
          }
          it1 = find(v[0].begin(), v[0].end(), i / 10);
          it2 = find(v[2].begin(), v[2].end(), i % 10);
          if (it1 != v[1].end() && it2 != v[2].end()) {
            l = 1;
          }
        }
        if (st != v[2].end()) {
          vector<long long>::iterator it1, it2;
          it1 = find(v[1].begin(), v[1].end(), i % 10);
          it2 = find(v[0].begin(), v[0].end(), i / 10);
          if (it1 != v[1].end() && it2 != v[0].end()) {
            l = 1;
          }
          it1 = find(v[1].begin(), v[1].end(), i / 10);
          it2 = find(v[0].begin(), v[0].end(), i % 10);
          if (it1 != v[1].end() && it2 != v[0].end()) {
            l = 1;
          }
        }
        if (l == 0) break;
      }
      p = i;
    }
  }
  cout << p << endl;
}
