#include <bits/stdc++.h>
using namespace std;
long long MM = 1000000000;
long long mod = MM + 7;
long long MMM = 9223372036854775807;
long long GCD(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return GCD(y, x % y);
}
long long LCM(long long x, long long y) { return x / GCD(x, y) * y; }
int main() {
  long long n, m;
  cin >> n >> m;
  int a[3] = {};
  for (long long i = 0; i < 3; i++) a[i] = -1;
  long long s, c;
  bool x = true;
  for (long long i = 0; i < m; i++) {
    cin >> s >> c;
    if (a[s] != -1 && a[s] != c) x = false;
    a[s] = c;
  }
  if (!x) {
    cout << -1;
    return 0;
  }
  if (n == 1) {
    if (a[1] == -1)
      cout << 0;
    else
      cout << a[1];
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    if (a[i + 1] != -1)
      cout << a[i + 1];
    else if (i == 0)
      cout << 1;
    else
      cout << 0;
  }
}
