#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1), eps = 1e-8;
const int maxn = 1 << 17;
const int N = 1e5 + 10, M = N << 2;
int n, m;
int vis[N];
int a[N];
int main() {
  memset(a, -1, sizeof(a));
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    if (a[x] >= 0 && a[x] != y) {
      printf("-1");
      return 0;
    }
    a[x] = y;
  }
  if (a[1] == 0) {
    printf("-1");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1) {
      if (i != 1)
        a[i] = 0;
      else
        a[i] = 1;
    }
    printf("%d", a[i]);
  }
  return 0;
}
