#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int A, B, C, N;
  cin >> N;
  vector<int> vec(N, -1);
  vector<int>::iterator itr;
  cin >> A;
  for (int i = 0; i < int(A); i++) {
    cin >> B >> C;
    if (B == 1 && C == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (vec[B - 1] != -1) {
      if (vec[B - 1] != C) {
        cout << -1 << endl;
        return 0;
      }
    }
    vec[B - 1] = C;
  }
  if (vec[0] == -1) vec[0] = 1;
  for (int i = 0; i < int(N); i++) {
    if (vec[i] == -1) vec[i] = 0;
    cout << vec[i];
  }
  cout << endl;
}
