#include <bits/stdc++.h>
using namespace std;
long long n, m, a[5];
signed main() {
  long long x, y;
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) a[i] = -1;
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld", &x, &y);
    if (a[x] == -1)
      a[x] = y;
    else if (a[x] != y) {
      printf("-1");
      return 0;
    }
  }
  if (a[1] == 0)
    printf("-1");
  else {
    if (n == 1) {
      printf("%lld", max(a[1], 0ll));
      return 0;
    }
    a[1] = max(a[1], 1ll);
    for (long long i = 2; i <= n; i++) a[i] = max(a[i], 0ll);
    for (long long i = 1; i <= n; i++) printf("%lld", a[i]);
  }
  return 0;
}
