#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
const ll MOD = 1e9 + 7, N = 1e5 + 10;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, m;
  cin >> n >> m;
  if (n == 1 and m == 0) {
    cout << "0\n";
    return 0;
  }
  map<ll, ll> val;
  for (ll i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    if (val[a] == 0) {
      val[a] = b;
    } else {
      if (val[a] != b) {
        cout << "-1\n";
        return 0;
      }
    }
    if (a == 1 and b == 0) {
      cout << "-1\n";
      return 0;
    }
  }
  if (val[1]) {
    cout << val[1];
  } else {
    cout << 1;
  }
  for (ll i = 2; i < n + 1; i++) {
    if (val[i]) {
      cout << val[i];
    } else {
      cout << "0";
    }
  }
  return 0;
}
