#include <bits/stdc++.h>
using namespace std;
long long Digit(long long N) {
  long long res = 0;
  while (N) res++, N /= 10;
  return res;
}
long long Gcd(long long a, long long b) { return b ? Gcd(b, a % b) : abs(a); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "0";
    return 0;
  }
  long long a[n];
  for (long long i = 0; i < n; i++) a[i] = -1;
  long long x, y;
  bool flag = false;
  for (long long i = 0LL; i < (m); i++) {
    cin >> x >> y;
    if (flag == false && a[x - 1] == -1)
      a[x - 1] = y;
    else if (flag == false && a[x - 1] == y) {
    } else
      flag = true;
  }
  if (n == 1) {
    if (a[0] != -1)
      cout << a[0];
    else
      cout << "0";
    return 0;
  }
  if (flag || a[0] == 0) {
    cout << "-1";
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    if (i == 0 && a[i] == -1)
      cout << "1";
    else if (i != 0 && a[i] == -1)
      cout << "0";
    else
      cout << a[i];
  }
  return 0;
}
