#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> s(m);
  vector<int> c(m);
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  for (int i = 0; i < m; i++) {
    if (a[s[i] - 1] > 0) {
      a[s[i] - 1] = min(a[s[i] - 1], c[i]);
    } else {
      a[s[i] - 1] = c[i];
    }
  }
  if (n > 1) {
    if (a[0] == 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      cout << a[i];
      cout << endl;
    } else {
      cout << a[i];
    }
  }
  return 0;
}
