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