#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  bool judge = true;
  map<int, int> cond;
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) {
      judge = false;
      break;
    } else if (!cond.count(s)) {
      cond[s] = c;
    } else if (cond.count(s) && c != cond.at(s)) {
      judge = false;
      break;
    }
  }
  if (!judge) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < N; i++) {
      if (cond.count(i)) {
        cout << cond.at(i);
      } else if (i == 0) {
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << "" << endl;
  }
}
