#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> vvv(N, 0);
  for (long long i = 0; i < M; i++) {
    long long a, b;
    cin >> a >> b;
    if ((vvv[a - 1] != 0 && vvv[a - 1] != b) || (a == 1 && b == 0 && N != 1)) {
      cout << -1 << endl;
      return 0;
    }
    vvv[a - 1] = b;
  }
  for (long long i = 0; i < N; i++) {
    cout << vvv[i];
  }
  if (vvv[0] == 0 && N != 1) {
    vvv[0] = 1;
  }
  cout << endl;
}
