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