#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
bool prime(long long x) {
  for (long long i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
long long kai(long long x, long long y) {
  long long res = 1;
  for (long long i = x - y + 1; i <= x; i++) {
    res *= i;
    res %= 1000000007;
  }
  return res;
}
long long mod_pow(long long x, long long y, long long m) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % m;
    }
    x = x * x % m;
    y >>= 1;
  }
  return res;
}
long long comb(long long x, long long y) {
  if (y > x) return 0;
  return kai(x, y) * mod_pow(kai(y, y), 1000000007 - 2, 1000000007) %
         1000000007;
}
long long n, m;
pair<long long, long long> a[5];
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) cin >> a[i].first >> a[i].second;
  sort(a, a + m);
  if ((a[0].first == 1) && (a[0].second == 0) && (n != 1)) {
    cout << -1 << endl;
    return 0;
  }
  for (long long i = 0; i < m - 1; i++) {
    if ((a[i].first == a[i + 1].first) && (a[i].second != a[i + 1].second)) {
      cout << -1 << endl;
      return 0;
    }
  }
  long long k = 0;
  if (a[0].first == 1) {
    cout << a[0].second;
    while (1 == a[k].first) k++;
  } else
    cout << 1;
  for (long long i = 2; i <= n; i++) {
    if (i == a[k].first) {
      cout << a[k].second;
      while (i == a[k].first) {
        k++;
      }
    } else
      cout << 0;
  }
  cout << endl;
}
