#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;
int n, m, flag = 1, x, y, cnt[10];
int main() {
  memset(cnt, -1, sizeof(cnt));
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    if (cnt[x] != -1 && cnt[x] != y) {
      flag = 0;
    } else if (x == 1 && y == 0 && n > 1) {
      flag = 0;
    } else {
      cnt[x] = y;
    }
  }
  if (flag) {
    for (int i = 1; i <= n; i++) {
      if (cnt[i] == -1) {
        cnt[i] = 0;
      }
      if (cnt[1] == 0) {
        cnt[1] = 1;
      }
      printf("%d", cnt[i]);
    }
    printf("\n");
  } else {
    printf("-1\n");
  }
  return 0;
}
