#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, A = 0, B;
  cin >> N >> M;
  vector<int> C(N, -1);
  for (int i = 0; i < (int)(M); i++) {
    cin >> B;
    if (C.at(B - 1) == -1)
      cin >> C.at(B - 1);
    else {
      int D;
      cin >> D;
      if (C.at(B - 1) != D) {
        A = -1;
        break;
      }
    }
    if (C.at(0) == 0) {
      A = -1;
      break;
    }
  }
  if (A == -1)
    cout << -1 << endl;
  else {
    for (int i = 0; i < (int)(N); i++) {
      if (C.at(i) != -1)
        cout << C.at(i);
      else if (i != 0)
        cout << 0;
      else
        cout << 1;
    }
    cout << endl;
  }
}
