#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, s, c;
  bool exist = true;
  cin >> N >> M;
  vector<int> X(N, 10);
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    if (X[s - 1] != 10 && X[s - 1] != c)
      exist = false;
    else
      X[s - 1] = c;
  }
  if (N != 1 && X[0] == 0) exist = false;
  for (int i = 0; i < N; i++) {
    if (X[i] == 10 && i == 0) X[i] = 1;
    if (X[i] == 10 && i != 0) X[i] = 0;
  }
  if (!exist)
    cout << "-1" << endl;
  else {
    for (int i = 0; i < N; i++) {
      cout << X[i];
    }
    cout << endl;
  }
  return 0;
}
