#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<char> ans(N, '*');
  for (int i = 0; i < M; i++) {
    int s;
    char c;
    cin >> s >> c;
    if (ans.at(s - 1) == '*')
      ans.at(s - 1) = c;
    else if (ans.at(s - 1) != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (N >= 2 && ans.at(0) == '0') {
    cout << -1 << endl;
    return 0;
  }
  if (N == 1 && M == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (ans.at(0) == '*') ans.at(0) = '1';
  for (int i = 0; i < N; i++) {
    if (ans.at(i) == '*') ans.at(i) = '0';
    cout << ans.at(i) << endl;
  }
  return 0;
}
