#include <bits/stdc++.h>
using namespace std;
char s[10];
int a[10];
int n, m, x, c;
int main() {
  cin >> n >> m;
  bool flag = 1;
  memset(a, -1, sizeof(a));
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &c);
    if (a[x] != -1 && a[x] != c) flag = 0;
    a[x] = c;
  }
  if (n != 1 && a[1] == 0) flag = 0;
  if (!flag) {
    cout << -1;
  } else {
    for (int i = 1; i <= n; i++) {
      if (i == 1)
        cout << max(1, a[i]);
      else
        cout << max(0, a[i]);
    }
  }
  return 0;
}
