#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> s(m), c(m);
  for (ll i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
  }
  for (ll i = 0; i < 1000; i++) {
    string str = to_string(i);
    bool ok = true;
    for (ll j = 0; j < m; j++) {
      if ((ll)str.size() != n || str[s[j] - 1] - '0' != c[j]) {
        ok = false;
      }
    }
    if (ok) {
      cout << str << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
