#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<char> c(M);
  for (int i = 0; i < (int)(M); i++) {
    cin >> s[i] >> c[i];
  }
  for (int i = 0; i < (int)(1000); i++) {
    string nx = i + "";
    for (int j = 0; j < (int)(M); j++) {
      if (nx[s[j] - 1] != c[j]) {
        nx == "";
        break;
      }
      cout << nx << endl;
      return 0;
    }
    if (nx == "") {
      continue;
    }
  }
  return 0;
}
