#include <bits/stdc++.h>
using namespace std;
int a[5] = {10, 10, 10, 10, 10}, n, m, s, c;
bool flag = false;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &s, &c);
    if (s == 1 && c == 0 && n > 1) flag = true;
    if (s > 3) flag = true;
    if (a[s] != 10 && a[s] != c) flag = true;
    a[s] = c;
  }
  if (flag) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i)
    if (a[i] == 10) a[i] = 0;
  if (a[1] == 0) a[1] = 1;
  for (int i = 1; i <= n; ++i) printf("%d", a[i]);
  printf("\n");
  return 0;
}
