#include <bits/stdc++.h>
using namespace std;
int n, m, a[11], vis[11];
int qpow(int a, int b) {
  int re = 1;
  while (b) {
    if (b & 1) re = re * a;
    b >>= 1;
    a = a * a;
  }
  return re;
}
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
signed main() {
  n = read(), m = read();
  bool flag = 0;
  int val = qpow(10, n - 1) - 1, v = 0;
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    if (vis[x] && a[x] != y) flag = 1;
    a[x] = y;
    vis[x] = 1;
  }
  if (flag) return puts("-1"), 0;
  if (vis[1] && !a[1]) return puts("-1"), 0;
  if (!a[1]) a[1] = 1;
  for (int i = 1; i <= n; i++) v = v * 10 + a[i];
  if (v <= val)
    puts("-1");
  else
    printf("%d\n", v);
  return 0;
}
