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