#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  map<int, int> mp;
  int ans = -1;
  string ans_ = "1";
  for (int i = 0; i < N - 1; i++) {
    ans_ += "0";
  }
  for (int i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
    if (mp.find(s.at(i)) == mp.end()) {
      mp[s.at(i)] = c.at(i);
    } else if (mp[s.at(i)] == c.at(i)) {
      mp[s.at(i)] = c.at(i);
    } else {
      cout << ans << endl;
      return 0;
    }
  }
  if (mp.find(1) != mp.end()) {
    if (mp[1] == 0) {
      cout << ans << endl;
      return 0;
    }
  }
  for (int i = 0; i < M; i++) {
    ans_.replace(s.at(i) - 1, 1, to_string(c.at(i)));
  }
  cout << ans_ << endl;
  return 0;
}
