#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  char ans[] = "nnn";
  scanf("%d%d", &n, &m);
  for (int i = 0, s, c; i < m; ++i) {
    scanf("%d%d", &s, &c);
    if (ans[s - 1] == 'n') {
      ans[s - 1] = c + '0';
    } else {
      if (ans[s - 1] != c + '0') {
        printf("-1\n");
        return 0;
      }
    }
  }
  if (n == 1 && ans[0] == '0') {
    printf("0\n");
    return 0;
  }
  if (ans[0] == '0') {
    printf("-a1\n");
    return 0;
  }
  if (ans[0] == 'n') {
    ans[0] = '1';
  }
  if (ans[1] == 'n') {
    ans[1] = '0';
  }
  if (ans[2] == 'n') {
    ans[2] = '0';
  }
  for (int i = 0; i < n; ++i) {
    printf("%c", ans[i]);
  }
  printf("\n");
}
