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