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