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