#include <bits/stdc++.h>
using namespace std;
int n, m;
int s[100001];
int c[100001];
int a[100001];
signed main() {
  scanf("%d%d", &n, &m);
  memset(a, -1, sizeof(a));
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &s[i], &c[i]);
    if (a[s[i]] != -1 && a[s[i]] != c[i]) {
      printf("-1");
      return 0;
    }
    a[s[i]] = c[i];
  }
  if (a[1] == 0) {
    printf("-1");
    return 0;
  } else if (a[1] == -1)
    a[1] = 1;
  for (int i = 1; i <= n; i++)
    if (a[i] == -1) a[i] = 0;
  for (int i = 1; i <= n; i++) printf("%d", a[i]);
  return 0;
}
