#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, x, y, cant = 0;
  cin >> n >> m;
  int a[n];
  for (i = 0; i < n; i++) {
    a[i] = -1;
  }
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    if (a[x - 1] == -1 || a[x - 1] == y) {
      a[x - 1] = y;
      if (a[0] == 0) {
        cant = 1;
      }
    } else {
      cant = 1;
    }
  }
  if (cant) {
    cout << -1;
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (a[i] == -1 && i >= 1) {
      a[i] = 0;
    } else if (a[i] == -1 && i == 0) {
      a[i] = 1;
    }
    cout << a[i];
  }
}
