#include <bits/stdc++.h>
using namespace std;
class CGuessTheNumber {
 public:
  void solve(std::istream& cin, std::ostream& cout) {
    long long N, M;
    cin >> N >> M;
    bool ok = true;
    map<long long, long long> pos;
    for (long long i = 0, i_len = (M); i < i_len; ++i) {
      long long s, c;
      cin >> s >> c;
      s--;
      if (pos.count(s) > 0 && pos[s] != c) {
        ok = false;
      }
      pos[s] = c;
    }
    if (!ok) {
      cout << -1 << endl;
      return;
    }
    if (pos[0] == 0 && N > 1) {
      cout << -1 << endl;
      return;
    }
    string res;
    for (long long i = 0, i_len = (N); i < i_len; ++i) {
      if (pos.count(i) > 0) {
        res += pos[i] + '0';
      } else {
        if (i == 0) {
          res += '1';
        } else {
          res += '0';
        }
      }
    }
    cout << res << endl;
  }
};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  CGuessTheNumber solver;
  solver.solve(in, out);
  return 0;
}
