#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  while (min(a, b) > 0) {
    if (a < b) swap(a, b);
    a %= b;
  }
  return max(a, b);
}
long long dx[] = {0, 1, 0, -1, 1, -1, -1, 1};
long long dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const long long MOD = 1e9 + 7;
const long long INF = 1e10 + 10;
signed main() {
  long long n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << 1 * pow(10, n - 1) << endl;
    return 0;
  }
  vector<long long> ans(n, -1);
  ;
  for (long long i = 0; i < (m); i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    if (n > 1 && x == 0 && y == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (ans[x] == y)
      continue;
    else if (ans[x] == -1)
      ans[x] = y;
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (ans[0] == -1) ans[0] = 1;
  if (n > 1) {
    if (ans[1] == -1) ans[1] = 0;
  }
  if (n > 2) {
    if (ans[2] == -1) ans[2] = 0;
  };
  for (long long i = 0; i < (n); i++) cout << ans[i];
  cout << endl;
  return 0;
}
