#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);
    if ((ll) str.size() != n) continue;
    bool ok = true;
    for (ll j = 0; j < m; j++) {
      if (str[s[j] - 1] - '0' != c[j]) ok = false;
    }
    if (ok) {
      cout << str << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
