#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  int nombre[N];
  for (int i = 0; i < N; i++) nombre[i] = -1;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    if (nombre[a] != -1 && nombre[a] != b) {
      cout << -1 << endl;
      exit(0);
    }
    nombre[a] = b;
  }
  if (nombre[0] == 0) {
    cout << -1 << endl;
    exit(0);
  }
  bool ok = false;
  for (int i = 0; i < N; i++) {
    if (nombre[i] != -1) {
      ok = true;
      cout << nombre[i];
    } else {
      if (!ok) {
        cout << 1;
        ok = true;
      } else
        cout << 0;
    }
  }
  cout << endl;
}
