#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m);
  vector<int> c(m);
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
  }
  for (int num = pow(10, (n - 1)); num < pow(10, n); num++) {
    bool isOk = true;
    for (int i = 0; i < m; i++) {
      if ((int)(num / pow(10, (n - s[i]))) % 10 != c[i]) {
        isOk = false;
      }
    }
    if (isOk) {
      cout << num << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
