#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> cond(m);
  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    cond[i] = make_pair(s, c);
  }
  int beg = pow(10, n - 1);
  if (beg == 1) beg = 1;
  for (int i = beg; i < pow(10, n); i++) {
    string str = to_string(i);
    int len = str.size();
    bool flag = true;
    for (int j = 0; j < m; j++) {
      int s = cond[j].first;
      char c = (char)(cond[j].second + '0');
      if (s > len) break;
      if (str[s - 1] != c) flag = false;
    }
    if (flag) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
