#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, i, t, j, k;
  scanf("%d%d", &n, &m);
  int a[1000];
  int x, val;
  memset(a, 0, sizeof(a));
  int wa = 0;
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x, &val);
    if (x == 1 && val == 0) {
      wa = 1;
      break;
    }
    if (a[x] != 0 && a[x] != val) {
      wa = 1;
      break;
    } else {
      a[x] = val;
    }
  }
  if (a[1] == 0 && n != 1) a[1] = 1;
  if (wa == 1)
    printf("-1");
  else
    for (i = 1; i <= n; i++) {
      printf("%d", a[i]);
    }
}
