#include <bits/stdc++.h>
using namespace std;
stringstream dout;
template <typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
  in >> p.first >> p.second;
  return in;
}
signed main(signed argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  const long long MOD = 1000000007;
  long long n, m;
  cin >> n >> m;
  string S(n, '0');
  S[0] = '1';
  vector<bool> b(n, false);
  for (long long i = 0; i < m; i++) {
    long long s, c;
    cin >> s >> c;
    if (n == 1) {
      cout << c << endl;
      return 0;
    }
    if ((s - 1 == 0 && c == 0) || b[s - 1]) {
      cout << -1 << endl;
      return 0;
    }
    S[s - 1] = char(c + '0');
    b[s - 1] = true;
  }
  cout << S << endl;
}
