#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> s.at(i) >> c.at(i);
  }
  vector<int> ret(n);
  for (int i = 0; i < (int)(m); i++) {
    ret.at(s.at(i) - 1) = c.at(i);
  }
  if (n != 1 and ret.at(0) == 0) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < (int)(n); i++) {
      cout << ret.at(i);
    }
    cout << endl;
  }
}
