#include <bits/stdc++.h>
using namespace std;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const int64_t INF = 1LL << 60;
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : abs(a);
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
int main() {
  int n, m;
  cin >> n >> m;
  int mx = 1;
  for (int i = 0; i < (int)(n); i++) mx *= 10;
  vector<bool> ans(mx, true);
  ans[0] = false;
  ;
  for (int i = 0; i < (int)(m); i++) {
    int s, c;
    cin >> s >> c;
    for (int j = 1; j < mx; j++)
      if (to_string(j)[s - 1] != c + '0') ans[j] = false;
  }
  int i = 0;
  while (!ans[i]) i++;
  cout << i << endl;
}
