#include <bits/stdc++.h>
using namespace std;
int constraints[3] = {-1, -1, -1};
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    if (constraints[a] != -1 && constraints[a] != b || a == 0 && b == 0) {
      cout << -1;
      return 0;
    }
    constraints[a] = b;
  }
  cout << (constraints[0] == -1 ? 1 : constraints[0]);
  for (int i = 1; i < N; i++) {
    cout << (constraints[i] == -1 ? 0 : constraints[i]);
  }
}
