#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  vector<int> A(M);
  for (int i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
  }
  for (int i = 0; i < M; i++) {
    A.at(s.at(i) - 1) = c.at(i);
  }
  if (A.at(0) != 0) {
    for (int i = 0; i < M; i++) {
      cout << A.at(i);
    }
    cout << "\n";
  } else {
    cout << "-1\n";
  }
}
