#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> ANS(N, -1);
  for (int i = 0; i < M; i++) {
    long long S, C;
    cin >> S >> C;
    S--;
    if (ANS[S] >= 0 && ANS[S] != C) {
      cout << -1 << endl;
      return 0;
    }
    ANS[S] = C;
  }
  if (N == 1) {
    if (ANS[0] == -1)
      cout << 0 << endl;
    else
      cout << ANS[0] << endl;
    return 0;
  }
  if (ANS[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    if (ANS[i] == -1) {
      if (i == 0)
        cout << 1 << endl;
      else
        cout << 0;
    } else
      cout << ANS[i];
  }
  cout << endl;
}
