#include <bits/stdc++.h>
using namespace std;
const long long int MAX = 1000000000;
const long long int MOD = 1e9 + 7;
unsigned long long int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s,
    t, u, v, w, x, y, z;
long long int aabs(long long int a) {
  if (a < 0) return -a;
  return a;
}
long long int combination(long long int n, long long int r) {
  long long int nf = 1, rf = 1;
  if (r * 2 > n) r = n - r;
  for (long long int i = 1; i <= r; ++i) {
    nf = ((n - r + i) * nf) % MOD;
    rf = (i * rf) % MOD;
  }
  return (nf / rf);
}
long long int kaijo(long long int a) {
  long long int ans = 1;
  for (long long int i = 2; i <= a; ++i) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
long long int kaijo2(long long int n, long long int a) {
  long long int ans = 1;
  for (long long int i = 0; i < a; ++i) {
    ans *= (n - i);
    ans %= MOD;
  }
  return ans;
}
long long int calc(long long int a, long long int b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0) {
    long long int d = calc(a, b / 2);
    return (d * d) % MOD;
  } else
    return (a * calc(a, b - 1)) % MOD;
}
long long int comb(long long int n, long long int a) {
  long long int b = 1, c = 1;
  for (long long int i = 1; i <= a; ++i) {
    b = b * i % MOD;
    c = c * (n - i + 1) % MOD;
  }
  return c * calc(b, MOD - 2) % MOD;
}
int main(void) {
  cin >> n >> m;
  vector<int> aa(n, 0);
  vector<bool> bb(n, false);
  for (i = 0; i < m; ++i) {
    cin >> b >> c;
    if (bb[b - 1] && c > aa[b - 1]) {
      cout << -1 << endl;
      return 0;
    }
    aa[b - 1] = c;
    bb[b - 1] = true;
  }
  if (n != 1 && aa[0] == 0) {
    if (bb[0] == false) {
      aa[0] = 1;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (i = 0; i < n; ++i) cout << aa[i];
  cout << endl;
  return 0;
}
