#include <bits/stdc++.h>
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int lb, ub;
  if (n == 1) lb = 1, ub = 9;
  if (n == 2) lb = 10, ub = 99;
  if (n == 3) lb = 100, ub = 999;
  vector<pair<int, char> > query(m);
  for (int i = 0; i < m; i++) cin >> query[i].first >> query[i].second;
  for (int i = lb; i <= ub; i++) {
    string d = to_string(i);
    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (d[query[j].first - 1] != query[j].second) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << d << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}
