#include <bits/stdc++.h>
using ll = long long;
const ll INF = 1e15;
using namespace std;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vc<vc<T>>;
using pi = pair<ll, ll>;
using vi = vc<ll>;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  ll N, M;
  cin >> N >> M;
  string S;
  for (ll i = ll(0); i < ll(N); i++) S += '0';
  if (N != 0) S[0] = '1';
  map<ll, ll> m;
  bool can = true;
  for (ll i = ll(0); i < ll(M); i++) {
    ll a, b;
    cin >> a >> b;
    if (m[a]) {
      if (m[a] != b + 1) can = false;
    } else {
      m[a] = b + 1;
    }
    if (a == 1 && b == 0 && N != 1) can = false;
    S[a - 1] = (char)('0' + b);
  }
  if (can)
    cout << S << endl;
  else
    cout << -1 << endl;
}
