#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, M;
  cin >> N >> M;
  vector<long> s(M);
  vector<long> c(M);
  for (int i = 0; i < M; i++) cin >> s[i] >> c[i];
  vector<long> a(N, -1);
  for (int i = 0; i < M; i++) {
    if (a[s[i] - 1] == -1)
      a[s[i] - 1] = c[i];
    else {
      if (a[s[i] - 1] != c[i]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    if (a[0] == -1)
      a[i] = 1;
    else if (a[i] == -1)
      a[i] = 0;
  }
  if (a[0] == 0) {
    if (N != 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << a[i];
  }
  cout << endl;
}
