#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> sc_pairs(m);
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    sc_pairs[i] = {s, c};
  }
  int lo = pow(10, n - 1);
  int hi = pow(10, n) - 1;
  bool find = false;
  for (int num = lo; num <= hi; ++num) {
    string num_string = to_string(num);
    bool valid = true;
    for (const auto& p : sc_pairs) {
      int s, c;
      tie(s, c) = p;
      if (num_string[s - 1] - '0' != c) {
        valid = false;
        break;
      }
    }
    if (valid) {
      cout << num << endl;
      find = true;
      break;
    }
  }
  if (!find) cout << -1 << endl;
  return 0;
}
