#include <bits/stdc++.h>
using namespace std;
const vector<long long> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<long long> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const long long MOD = (1000000007);
const long long INF = (1LL << 60);
const double EPS = (1 >> 30);
template <class tuple<long long, long long, long long> >
inline bool chmin(tuple<long long, long long, long long>& a,
                  tuple<long long, long long, long long> b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
} template <class tuple<long long, long long, long long> >
inline bool chmax(tuple<long long, long long, long long>& a,
                  tuple<long long, long long, long long> b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
} long long gcd(long long x, long long y) {
  return y ? gcd(y, x % y) : x;
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
long long mod_pow(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % MOD;
    }
    x = x * x % MOD;
    y >>= 1;
  }
  return res;
}
long long comb(long long n, long long k) {
  k = min(k, n - k);
  long long nnn = 1;
  for (long long i = n - k + 1; i <= n; i++) {
    nnn *= i;
    nnn %= MOD;
  }
  long long kkk = 1;
  for (long long i = 1; i <= k; i++) {
    kkk *= i;
    kkk %= MOD;
  }
  return (nnn * mod_pow(kkk, MOD - 2)) % MOD;
}
long long to_int(string s) {
  long long n = s.size();
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    ans = ((ans * 10) + (s[i] - '0')) % MOD;
  }
  return ans;
}
bool is_prime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}
long long extgcd(long long a, long long b, long long& x, long long& y) {
  long long d = a;
  if (d != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1, y = 0;
  }
  return 0;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > scc(m);
  for (long long i = 0; i < m; ++i) cin >> scc[i].first >> scc[i].second;
  sort((scc).begin(), (scc).end());
  long long ng = 0;
  for (long long i = 0; i < m - 1; ++i) {
    if (scc[i].first == scc[i + 1].first && scc[i].second != scc[i + 1].second)
      ng++;
  }
  for (long long i = 0; i < m; ++i) {
    if (scc[i].first == 1 && scc[i].second == 0) ng++;
  }
  if (ng > 0) {
    cout << -1 << endl;
  } else {
    vector<long long> ans(n, -1);
    for (long long i = 0; i < m; ++i) {
      long long keta = scc[i].first - 1;
      ans[keta] = scc[i].second;
    }
    if (ans[0] == -1) ans[0] = 1;
    for (long long i = 0; i < n; ++i) {
      if (ans[i] == -1) ans[i] = 0;
    }
    for (long long i = 0; i < n; ++i) {
      cout << ans[i];
    }
    cout << endl;
  }
}
