#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int digits[3] = {0, 0, 0};
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    digits[s - 1] = c;
  }
  if (N != 1 && digits[0] == 0)
    cout << -1;
  else {
    int sum = 0;
    for (int i = 0; i < N; i++) sum = sum * 10 + digits[i];
    cout << sum;
  }
}
