#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
int a[maxn];
int main() {
  memset(a, -1, sizeof(a));
  int n, m, f = 0;
  scanf("%d%d", &n, &m);
  if (n == 1 && !m) return puts("0"), 0;
  for (int i = 1, s, c; i <= m; i++) {
    scanf("%d%d", &s, &c);
    if (a[s] == -1)
      a[s] = c;
    else {
      if (a[s] != c) f = 1;
    }
  }
  if (f || (n != 1 && a[1] == 0)) return puts("-1"), 0;
  printf("1");
  for (int i = 2; i <= n; i++) {
    printf("%d", (a[i] == -1 ? 0 : a[i]));
  }
  puts("");
  return 0;
}
