#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f;
int main() {
  int n, m;
  cin >> n >> m;
  int s, c, fg = 1;
  int a[4];
  for (int i = 1; i <= 3; i++) a[i] = -1;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &s, &c);
    if (a[s] != -1 && a[s] != c) fg = 0;
    a[s] = c;
  }
  if (a[1] == 0) fg = 0;
  if (fg == 0)
    printf("-1");
  else {
    for (int i = 1; i <= n; i++) {
      if (i == 1 && a[i] == -1)
        printf("1");
      else if (i != 1 && a[i] == -1)
        printf("0");
      else
        printf("%d", a[i]);
    }
  }
  return 0;
}
