#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s[M], c[M];
  for (int i = 0; i < M; ++i) {
    cin >> s[i];
    cin >> c[i];
  }
  int ans = 0;
  map<int, int> m;
  string S;
  bool OK;
  for (int i = 0; i < 1000; ++i) {
    S = to_string(i);
    if (S.size() != N) continue;
    OK = true;
    for (int j = 0; j < M; ++j) {
      if (S[s[j] - 1] != ('0' + c[j])) OK = false;
    }
    if (OK) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}
