#include <bits/stdc++.h>
using namespace std;
int N, M;
int A[5];
int main() {
  cin >> N >> M;
  int pos, num;
  memset(A, -1, sizeof(A));
  for (int i = 1; i <= M; i++) {
    cin >> pos >> num;
    if ((A[pos] == -1 || A[pos] == num) && pos <= N) {
      A[pos] = num;
    } else {
      puts("-1");
      return 0;
    }
  }
  bool nozero = 1;
  if (A[1] == 0) {
    puts("-1");
    return 0;
  }
  for (int i = 1; i <= N; i++) {
    if (A[i] == -1) {
      cout << 1;
    } else
      cout << A[i];
  }
  cout << "\n";
  return 0;
}
