#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class... Args>
void dump(Args&&... args) {}
ll solve() {
  ll n, m;
  cin >> n >> m;
  vector<ll> v(n, -1);
  for (ll i = (ll)(0); i < (ll)((m)); i++) {
    ll s, c;
    cin >> s >> c;
    s--;
    if (v[s] != -1 && v[s] != c) return -1;
    if (s == 0 && c == 0 && n != 1) return -1;
    v[s] = c;
  }
  if (n != 1) {
    for (ll i = (ll)(0); i < (ll)((n)); i++) {
      if (v[i] == -1) {
        v[i] = 1;
      } else {
        for (ll j = (ll)(i + 1); j < (ll)(n); j++) {
          if (v[j] == -1) v[j] = 0;
        }
        break;
      }
    }
  }
  if (n == 1 && m == 0) return 0;
  for (auto x : v) cout << x;
  cout << endl;
  exit(0);
}
signed main() {
  cout << solve() << endl;
  return 0;
}
