#include <bits/stdc++.h>
int main() {
  long long int N, M;
  std::cin >> N >> M;
  long long int data[2][M];
  for (int i = 0; i < M; ++i) {
    std::cin >> data[0][i] >> data[1][i];
  }
  long long int an[N];
  for (int i = 0; i < N; ++i) an[i] = 0;
  for (int i = 0; i < M; ++i) {
    an[data[0][i] - 1] = data[1][i];
  }
  long long int num = 0;
  if (an[0] == 0)
    std::cout << "-1" << std::endl;
  else {
    for (int i = 0; i < N; ++i) {
      num += pow(10, N - 1 - i) * an[i];
    }
    std::cout << num << std::endl;
  }
  return 0;
}
