#include <bits/stdc++.h>
using namespace std;
int n, m, x, y;
bool flag = 1;
int f[10];
int main() {
  memset(f, -1, sizeof(f));
  cin >> n >> m;
  while (m--) {
    cin >> x >> y;
    if (!flag) continue;
    if ((x == 1 && !y) || (f[x] != -1 && f[x] != y)) flag = 0;
    f[x] = y;
  }
  if (!flag) {
    puts("-1");
    return 0;
  }
  if (f[1] == -1)
    putchar('1');
  else
    putchar(f[1] ^ 48);
  for (int i = 2; i <= n; i++) {
    if (f[i] == -1)
      putchar('0');
    else
      putchar(f[i] ^ 48);
  }
  putchar('\n');
  return 0;
}
