#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  vector<long long> ans(N);
  for (long long i = 0; i < N; i++) ans[i] = -1;
  bool F = true;
  for (long long i = 0; i < M; i++) {
    long long s, c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == 0) F = false;
    if (ans[s] != -1 && ans[s] != c) {
      F = false;
    } else {
      ans[s] = c;
    }
  }
  for (long long i = 0; i < N; i++) {
    if (ans[i] == -1) {
      if (i == 0)
        ans[i] = 1;
      else
        ans[i] = 0;
    }
  }
  if (F) {
    for (long long i = 0; i < N; i++) cout << ans[i];
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
