#include <bits/stdc++.h>
using namespace std;
long long N, M, A[3];
signed main() {
  cin >> N >> M;
  for (long long i = 0; i < N; i++) A[i] = -1;
  for (long long i = 0; i < M; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    if (A[a] != -1 && A[a] != b) {
      cout << "-1" << endl;
      return 0;
    }
    if (a == 0 && b == 0 && N > 1) {
      cout << "-1" << endl;
      return 0;
    }
    A[a] = b;
  }
  for (long long i = 0; i < N; i++) {
    if (A[i] == -1) {
      if (i == 0)
        cout << 1;
      else
        cout << 0;
    } else
      cout << A[i];
  }
  cout << endl;
  return 0;
}
