#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  vector<int> h(N + 1);
  int flag = 0;
  for (int i = 0; i < M; i++) {
    cin >> s[i];
    cin >> c[i];
    h[s[i]] = c[i];
  }
  int j = 1;
  while (j <= N) {
    if (h[1] == 0) {
      cout << -1 << endl;
      break;
    } else {
      cout << h[j];
    }
    j++;
  }
  cout << endl;
  return 0;
}
