#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N);
  vector<bool> is_fix(N);
  for (int i = 0; i < (int)(M); i++) {
    int keta, num;
    cin >> keta >> num;
    keta--;
    if (keta == 0 && num == 0) {
      cout << "-1" << endl;
      return 0;
    }
    if (!is_fix[keta]) {
      is_fix[keta] = true;
      ans[keta] = num;
    } else if (ans[keta] != num) {
      cout << "-1" << endl;
      return 0;
    }
  }
  for (int i = 0; i < (int)(N); i++) {
    if (!is_fix[i]) {
      ans[i] = (i == 0) ? 1 : 0;
    }
    cout << ans[i];
  }
  cout << endl;
}
