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