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