#include <bits/stdc++.h>
using namespace std;
int main() {
  bool f = true;
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m), ans(n, -1);
  for (long long i = 0, i_len = (m); i < i_len; ++i) {
    cin >> s.at(i) >> c.at(i);
  }
  for (long long i = 0, i_len = (m); i < i_len; ++i) {
    if (ans.at(s.at(i) - 1) == -1)
      ans.at(s.at(i) - 1) = c.at(i);
    else if (ans.at(s.at(i) - 1) != c.at(i))
      f = false;
    if (s.at(i) == 1 && c.at(i) == 0) f = false;
  }
  if (ans.at(0) == 0) ans.at(0) = 1;
  for (long long i = 0, i_len = (n); i < i_len; ++i) {
    if (ans.at(i) == -1) ans.at(i) = 0;
  }
  if (f) {
    for (long long i = 0, i_len = (n); i < i_len; ++i) {
      cout << ans.at(i);
    }
    cout << "\n";
  } else {
    cout << -1 << "\n";
  }
  return 0;
}
