#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b);
long long int power(long long int n, long long int k);
long long int inv(long long int n);
long long int genfact(long long int n, long long int k);
long long int fact(long long int n);
long long int nck(long long int n, long long int k);
int main(void) {
  int n, m;
  cin >> n >> m;
  int kotae[10] = {};
  int ok = 1;
  for (int i = 0; i < 10; i++) {
    kotae[i] = -1;
  }
  long long int s, c;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      ok = 0;
    } else if (s >= n) {
      ok = 0;
    } else if (kotae[s] == -1) {
      kotae[s] = c;
    } else if (kotae[s] > 0 && kotae[s] != c) {
      kotae[s] = -2;
      ok = 0;
    }
  }
  if (ok) {
    if (kotae[0] == -1) {
      cout << "1";
    } else {
      cout << kotae[0];
    }
    for (int i = 1; i < n; i++) {
      if (kotae[i] == -1)
        cout << "0";
      else
        cout << kotae[i];
    }
    cout << endl;
  } else
    cout << -1 << endl;
  return 0;
}
long long int gcd(long long int a, long long int b) {
  if (a < b) return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int power(long long int n, long long int k) {
  long long int res = 1;
  while (k > 0) {
    if (k & 1) res = res * n % 1000000007;
    n = n * n % 1000000007;
    k >>= 1;
  }
  return res;
}
long long int genfact(long long int n, long long int k) {
  long long int res = 1;
  while (k >= 0) {
    res = (res * (n - k)) % 1000000007;
    k--;
  }
  return res;
}
long long int inv(long long int n) { return power(n, 1000000007 - 2); }
long long int fact(long long int n) { return genfact(n, n - 1); }
long long int nck(long long int n, long long int k) {
  if (k == 0) return 1;
  if (n <= 0) return 0;
  return ((genfact(n, k) % 1000000007) * inv(fact(k))) % 1000000007;
}
