#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];
  for (int i = 0; i < (int)pow(10, n); ++i) {
    bool flag = false;
    for (int j = 0; j < m; ++j) {
      if ((i / (int)pow(10, n - s[j])) % 10 != c[j] ||
          i / (int)pow(10, n - s[j]) == 0) {
        flag = true;
        break;
      }
    }
    if (!flag) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
