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