#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, s, c;
  int ans[N];
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    ans[i] = 11;
  }
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    if (ans[s - 1] == 11) {
      ans[s - 1] = c;
    } else if (ans[s - 1] == c) {
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  int top0 = 0;
  if (ans[0] == 0) top0 = 1;
  for (int i = 0; i < N; i++) {
    if (top0) {
      cout << -1 << endl;
      return 0;
    } else {
      if (ans[i] == 11) {
        if (i == 0) {
          ans[i] = 1;
        } else {
          ans[i] = 0;
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i];
  }
  cout << endl;
}
