#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > constraints;
  for (int i = 0; i < M; i++) {
    int ci, si;
    cin >> ci >> si;
    constraints.push_back(make_pair(ci, si));
  }
  int answer = -1;
  for (int num = (int)pow(10, N - 1); num < pow(10, N); num++) {
    string curnum = to_string(num);
    int ci, si;
    bool valid = true;
    for (int j = 0; j < constraints.size(); j++) {
      si = constraints[j].first;
      ci = constraints[j].second;
      if (curnum[si - 1] != (char)('0' + ci)) {
        valid = false;
        break;
      }
    }
    if (valid) {
      answer = num;
      break;
    }
  }
  cout << answer << "\n";
  return 0;
}
