#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<int> num(N);
  for (int i = 0; i < M; ++i) {
    int s, c;
    cin >> s >> c;
    num[s - 1] = c;
  }
  if (num[0] == 0) {
    goto error;
  }
  for (auto v : num) {
    cout << v;
  }
  cout << endl;
  return 0;
error:
  cout << -1 << endl;
}
