#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  for (int(i) = (0); (i) < (int)(M); (i)++) {
    cin >> s.at(i);
    cin >> c.at(i);
  }
  vector<int> target_int(N, 0);
  int res = 0;
  for (int(i) = (0); (i) < (int)(M); (i)++) {
    if (target_int.at(s.at(i) - 1) == 0) {
      target_int.at(s.at(i) - 1) = c.at(i);
    } else {
      if (target_int.at(s.at(i) - 1) != c.at(i)) res = -1;
    }
  }
  for (int(i) = (0); (i) < (int)(M); (i)++) {
    if (s.at(i) == 1 && c.at(i) == 0) res = -1;
  }
  if (target_int.at(0) == 0) target_int.at(0) = 1;
  if (res != -1) {
    for (int(i) = (0); (i) < (int)(N); (i)++) {
      cout << target_int.at(i);
    }
  } else {
    cout << res;
  }
}
