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