#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> ans(N);
  vector<bool> ok(N, true);
  for (long long i = 0; i < M; i++) {
    long long s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (ok[s - 1]) {
      ans[s - 1] = c;
      ok[s - 1] = false;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (long long i = 0; i < N; i++) {
    cout << ans[i];
  }
  cout << endl;
}
