#include <bits/stdc++.h>
int main() {
  using namespace std;
  int N, M;
  cin >> N >> M;
  vector<int> s_i(M);
  vector<int> c_i(M);
  for (int i = 0; i < M; i++) {
    cin >> s_i.at(i) >> c_i.at(i);
  }
  vector<int> num(N);
  for (int i = 0; i < M; i++) {
    int p = s_i.at(i);
    int q = c_i.at(i);
    num.at(p - 1) = q;
  }
  if (num.at(0) == 0) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < M; i++) {
    cout << num.at(i);
  }
  cout << endl;
  return 0;
}
