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