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