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