#include <bits/stdc++.h>
using namespace std;
int num[10];
int main() {
  int n, m;
  cin >> n >> m;
  memset(num, -1, sizeof(num));
  int s, c;
  bool flag = true;
  for (int i = 0; i < m; ++i) {
    cin >> s >> c;
    if (num[s - 1] == -1) {
      num[s - 1] = c;
    }
    if (num[s - 1] != c) {
      flag = false;
    }
  }
  if (n == 1) {
    printf("%d\n", max(0, num[0]));
    return 0;
  }
  if (!flag || num[0] == 0) {
    printf("-1\n");
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if (num[i] == -1) {
      if (num[0] == -1) {
        num[i] = 1;
      } else
        num[i] = 0;
    }
  }
  for (int i = 0; i < n; ++i) printf("%d", num[i]);
}
