#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int pow1(long long int x, unsigned long long int y) {
  long long int temp;
  if (y == 0) return 1;
  temp = pow1(x, y / 2);
  if (y % 2 == 0)
    return (temp * temp) % (long long int)(1e9 + 7);
  else
    return ((x * temp) % (long long int)(1e9 + 7) * (temp) %
            (long long int)(1e9 + 7)) %
           (long long int)(1e9 + 7);
}
long long int inv_mod(long long int a) {
  long long int res = 1;
  long long int mod_temp = (long long int)(1e9 + 7) - 2;
  while (mod_temp) {
    if (mod_temp & 1) {
      res =
          ((res % (long long int)(1e9 + 7)) * (a % (long long int)(1e9 + 7))) %
          (long long int)(1e9 + 7);
    }
    a = ((a % (long long int)(1e9 + 7)) * (a % (long long int)(1e9 + 7))) %
        (long long int)(1e9 + 7);
    mod_temp >>= 1;
  }
  return res % (long long int)(1e9 + 7);
}
long long int ncr(long long int n, long long int k) {
  long long int res = 1;
  if (k > n - k) k = n - k;
  for (long long int i = 0; i < k; ++i) {
    res = ((res % (long long int)(1e9 + 7)) *
           ((n - i) % (long long int)(1e9 + 7))) %
          (long long int)(1e9 + 7);
    res = ((res % (long long int)(1e9 + 7)) *
           (inv_mod(i + 1) % (long long int)(1e9 + 7))) %
          (long long int)(1e9 + 7);
  }
  return res % (long long int)(1e9 + 7);
}
long long int fibonacci(long long int n) {
  double phi = (1LL + sqrt(5)) / (double)2;
  long long int nth_fib = round(pow(phi, n) / sqrt(5));
  return nth_fib;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n >> m;
  long long int arr[n];
  memset(arr, -1, sizeof(arr));
  for (long long int i = 0; i < m; i++) {
    long long int set1, c;
    cin >> set1 >> c;
    set1--;
    if ((arr[set1] != -1 && c != arr[set1]) || (set1 == 0 && c == 0)) {
      cout << "-1\n";
      return 0;
    } else {
      arr[set1] = c;
    }
  }
  if (arr[0] == -1) arr[0] = 1;
  for (long long int i = 1; i < n; i++) {
    if (arr[i] == -1) arr[i] = 0;
  }
  for (long long int i = 0; i < n; i++) cout << arr[i];
  return 0;
}
