#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int s, c;
  vector<vector<int>> conditions(M, vector<int>(2));
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    conditions.at(i) = {s, c};
  }
  bool acceptable = true;
  int result = -1;
  for (int i = pow(10, (N - 1)); i < pow(10, N); i++) {
    for (vector<int> cond : conditions) {
      int temp = i % (int)pow(10, (N - cond.at(0) + 1));
      temp = temp / (int)pow(10, (N - cond.at(0)));
      if (temp != cond.at(1)) {
        acceptable = false;
        break;
      }
    }
    if (acceptable == true) {
      result = i;
      break;
    } else {
      acceptable = true;
      continue;
    }
  }
  cout << result;
  return 0;
}
