#include <bits/stdc++.h>
using namespace std;
inline void solve() {
  long long n, m;
  cin >> n >> m;
  vector<long long> digit(n + 1, -1);
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    if (digit[a] != -1 and digit[a] != b) cout << -1, exit(0);
    digit[a] = b;
  }
  bool ok = false;
  for (long long i = 1; i <= n; i++) {
    if (digit[i] == -1) {
      if (ok)
        digit[i] = 0;
      else
        digit[i] = 1;
    } else
      ok = true;
  }
  if (n > 1 and digit[1] == 0)
    cout << -1 << endl;
  else
    for (long long i = 1; i <= n; i++) cout << digit[i];
}
signed main() {
  long long n = 1;
  while (n--) solve();
  return 0;
}
