#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
template <class T, class U>
bool cmax(T& a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U>
bool cmin(T& a, U b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vl a(n, -1);
  for (ll i = 0; i < m; i++) {
    ll s, c;
    cin >> s >> c;
    if (a[n - s] == -1) {
      a[n - s] = c;
    } else {
      if (a[n - s] != c) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (n == 1 and a[0] == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (n >= 2 and a[n - 1] == 0) {
    cout << -1 << endl;
    return 0;
  }
  bool f = 0;
  vl ans(n);
  for (ll i = n - 1; i >= 0; i--) {
    if (a[i] == -1) {
      if (f) {
        ans[i] = 0;
      } else {
        ans[i] = 1;
        f = 1;
      }
    } else {
      ans[i] = a[i];
      f = 1;
    }
  }
  for (ll i = n - 1; i >= 0; i--) {
    cout << ans[i];
  }
  cout << endl;
}
