#include <bits/stdc++.h>
using namespace std;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long modpow(long long n, long long k) {
  if (k == 1) {
    return n;
  } else if (k == 0) {
    return 1;
  } else if (k % 2 == 0) {
    long long memo = modpow(n, k / 2) % 1000000007;
    return memo * memo % 1000000007;
  } else {
    return n * modpow(n, k - 1) % 1000000007;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) {
    a[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (x == 1 && y == 0) {
      cout << -1 << endl;
      return 0;
    }
    x--;
    if (a[x] != -1 && a[x] != y) {
      cout << -1 << endl;
      return 0;
    } else {
      a[x] = y;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) {
      if (i == 0) {
        cout << 1;
      } else {
        cout << 0;
      }
    } else {
      cout << a[i];
    }
  }
  cout << endl;
  return 0;
}
