#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int ss[N];
  for (int i = 0; i < N; i++) {
    ss[i] = -1;
  }
  for (int _ = 0; _ < M; _++) {
    int s, c;
    cin >> s >> c;
    if (ss[s - 1] != -1 && ss[s - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
    ss[s - 1] = c;
  }
  if (ss[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << (ss[0] == -1 ? 1 : ss[0]);
  for (int i = 1; i < N; i++) {
    cout << (ss[i] == -1 ? 0 : ss[i]);
  }
  cout << endl;
  return 0;
}
