#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long log(long long a) {
  long long b = a;
  long long cnt = 0;
  while (b % 2 == 0) {
    b /= 2;
    cnt++;
  }
  return cnt;
}
long long mypow(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long t = mypow(a, b / 2);
  if (b % 2 == 0) return t * t;
  return t * t * a;
}
long long n, m;
long long c[7];
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < n + 1; i++) c[i] = -1;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    if (c[x] == -1 || c[x] == y)
      c[x] = y;
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (m == 0) {
    if (n == 1)
      cout << 0;
    else {
      cout << 1;
      for (long long i = 0; i < n - 1; i++) cout << 0;
      cout << endl;
    }
    return 0;
  }
  if (c[1] <= 0 && n != 1) {
    c[1] = 1;
  }
  for (long long i = 0; i < n; i++) {
    if (c[i + 1] == -1)
      cout << 0;
    else
      cout << c[i + 1];
  }
  cout << endl;
  return 0;
}
