#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[11];
int main() {
  scanf("%d%d", &n, &m);
  memset(a, -1, sizeof a);
  bool chk = true;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (a[x] < 0)
      a[x] = y;
    else if (a[x] != y)
      chk = false;
  }
  if (n > 1 && a[1] == 0) chk = false;
  if (!chk)
    puts("-1");
  else {
    for (int i = 1; i <= n; i++)
      if (a[i] < 0) a[i] = (i == 1 ? 1 : 0);
    for (int i = 1; i <= n; i++) printf("%d", a[i]);
    puts("");
  }
  return 0;
}
