#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M, -1);
  for (int i = 0; i < M; i++) {
    int j, k;
    cin >> j >> k;
    if (s[j - 1] >= 0 && s[j - 1] != k) {
      cout << -1 << endl;
      return 0;
    }
    if (N > 1 && j == 1 && k == 0) {
      cout << -1 << endl;
      return 0;
    }
    s[j - 1] = k;
  }
  vector<int> ans(N, 0);
  if (N > 1) {
    ans[0] = 1;
  }
  for (int i = 0; i < N; i++) {
    if (s[i] != -1) {
      ans[i] = s[i];
    }
  }
  int a = 0;
  for (int i = 0; i < N; i++) {
    cout << ans[i] << endl;
    a += ans[i] * pow(10, N - i - 1);
  }
  cout << a << endl;
}
