#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vc = vector<char>;
using vb = vector<bool>;
using vl = vector<ll>;
int main() {
  bool ok;
  int n, m, ans = -1;
  string si;
  char cc;
  cin >> n >> m;
  vi s(m);
  vi c(m);
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
  }
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    si = to_string(i);
    ok = true;
    for (int j = 0; j < m; j++) {
      if (si[s[j] - 1] - '0' != c[j]) {
        ok = false;
      }
    }
    if (ok) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
