#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long int n, m, c[3] = {-1, -1, -1}, a, b;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if ((c[a - 1] != -1 && c[a - 1] != b) || (a == 1 || b == 0)) {
      cout << -1;
      return 0;
    }
    c[a - 1] = b;
  }
  for (int i = 0; i < n; i++) {
    if (c[i] == -1) {
      c[i] = i ? 0 : 1;
    }
    cout << c[i];
  }
}
