#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  if (N != M) {
    cout << -1 << endl;
    return 0;
  }
  int X[N];
  for (int i = 0; i < N; i++) {
    X[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    X[s - 1] = c;
  }
  for (int i = 0; i < N; i++) {
    cout << X[i];
  }
  printf("\n");
}
