#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> res(n);
  for (long long i = 0; i < m; i++) {
    long long pos, x;
    cin >> pos >> x;
    pos--;
    if (res[pos]) {
      cout << -1 << '\n';
      return 0;
    }
    if (!pos && !x) {
      cout << -1 << '\n';
      return 0;
    }
    res[pos] = x;
  }
  if (!res[0]) res[0] = 1;
  for (long long i : res) cout << i;
  cout << '\n';
  return 0;
}
