#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
double pi = 3.1415926535;
int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m], y[3], x, c = 0, ans = 0;
  for (int i = 0; i < m; i++) cin >> a[i] >> b[i];
  if (n == 1) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < m; j++) {
        if (i == b[j]) c++;
      }
      if (c == m) {
        cout << i << endl;
        break;
      }
      c = 0;
    }
  }
  if (n == 2) {
    for (int i = 10; i < 100; i++) {
      for (int j = 0; j < m; j++) {
        if (a[j] == 1)
          if (i / 10 == b[j]) c++;
        if (a[j] == 2)
          if (i % 10 == b[j]) c++;
      }
      if (c == m) {
        cout << i << endl;
        break;
      }
      c = 0;
    }
  }
  if (n == 3) {
    for (int i = 100; i < 1000; i++) {
      for (int j = 0; j < m; j++) {
        if (a[j] == 1)
          if (i / 100 == b[j]) c++;
        if (a[j] == 2)
          if (i % 100 / 10 == b[j]) c++;
        if (a[j] == 3)
          if (i % 10 == b[j]) c++;
      }
      if (c == m) {
        cout << i << endl;
        break;
      }
      c = 0;
    }
  }
  return 0;
}
