#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, l, m, n;
  cin >> n >> m;
  int ar[n + 10];
  memset(ar, -1, sizeof ar);
  bool ok = true;
  for (i = 0; i < m; i++) {
    cin >> l >> k;
    if (ar[l] != -1 && ar[l] != k) ok = false;
    ar[l] = k;
  }
  if (ar[1] == 0) ok = false;
  if (!ok)
    cout << -1 << '\n';
  else {
    for (i = 2; i <= n; i++) {
      if (ar[i] == -1) ar[i] = 0;
    }
    if (ar[1] == -1) ar[1] = 1;
    for (i = 1; i <= n; i++) cout << ar[i];
    cout << '\n';
  }
}
