#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
int main() {
  int n, m;
  bool dpl = false;
  cin >> n >> m;
  vi fig(n, -1);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    if (fig[s - 1] == -1 || fig[s - 1] == c) {
      fig[s - 1] = c;
    } else {
      dpl = true;
    }
  }
  for (int i = 0; i < n; i++) {
    if (fig[i] == -1) {
      if (i == 0) {
        fig[i] = 1;
      } else {
        fig[i] = 0;
      }
    }
  }
  if (n != 1 && fig[0] == 0) {
    cout << -1 << endl;
  } else if (dpl) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < n; i++) {
      cout << fig[i];
    }
    cout << endl;
  }
}
