#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
  }
  vector<int> number(N, -1);
  bool flag = true;
  for (int i = 0; i < M; i++) {
    if (number.at(s.at(i) - 1) == -1) {
      number.at(s.at(i) - 1) = c.at(i);
    } else {
      if (number.at(s.at(i) - 1) != c.at(i)) {
        flag = false;
        break;
      }
    }
  }
  if (number.at(0) == 0) {
    flag = false;
  }
  if (flag) {
    for (int i = 0; i < N; i++) {
      if (number.at(i) == -1) {
        if (i == 0) {
          number.at(i) = 1;
        } else {
          number.at(i) = 0;
        }
      }
      cout << number.at(i);
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
}
