#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
using V = vector<T>;
using P = pair<long long, long long>;
signed main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> ma;
  char ans[n + 1];
  for (long long i = (long long)(0); i < (long long)(n); i++) ans[i] = '0';
  ans[0] = '1';
  ans[n] = '\0';
  for (long long i = (long long)(0); i < (long long)(m); i++) {
    long long s, c;
    cin >> s >> c;
    if (s == 1 and c == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (ma.count(s) > 0 and ma[s] != c) {
      cout << -1 << endl;
      return 0;
    }
    ma[s] = c;
    ans[s - 1] = c + '0';
  }
  cout << ans << endl;
  return 0;
}
