#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int e = 2000 + 69;
const int base = 311;
long long a[e], b[e];
int main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> kt;
  map<long long, long long> kt1;
  for (long long i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    if (kt[a[i]] == 0)
      kt[a[i]] = b[i];
    else
      kt[a[i]] = min(kt[a[i]], b[i]);
  }
  for (long long i = 1; i <= n; i++) {
    if (kt[1] == 0) {
      cout << -1;
      return 0;
    } else {
      cout << kt[i];
    }
  }
}
