#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m);
  vector<char> c(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> s[i] >> c[i];
  }
  int lim = pow(10, n);
  int min = pow(10, n - 1);
  string st;
  bool flag;
  for (int i = min; i < lim; i++) {
    st = to_string(i);
    flag = true;
    for (int j = 0; j < (int)(m); j++) {
      if (st[s[j] - 1] != c[j]) flag = false;
    }
    if (flag) {
      cout << st << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
