#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> A(N);
  int i;
  for (i = 0; i < M; i++) {
    cin >> S[i] >> C[i];
    if (A[S[i]] != 0)
      A[S[i]] = C[i];
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  for (i = 1; i <= N; i++) {
    cout << A[i];
  }
  cout << endl;
  return 0;
}
