#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int S, C;
  int none[3] = {1, 1, 1};
  int digit[3] = {1, 0, 0};
  int imp = 0;
  for (int i = 0; i < M; i++) {
    cin >> S >> C;
    if (imp) continue;
    if (S > N) {
      imp = 1;
      continue;
    }
    if (S == 1 && C == 0) {
      imp = 1;
      continue;
    }
    S--;
    if (none[S]) {
      none[S] = 0;
      digit[S] = C;
    } else {
      if (digit[S] != C) {
        imp = 1;
      }
    }
  }
  if (imp) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < N; i++) {
      cout << digit[i];
    }
    cout << endl;
  }
}
