#include <bits/stdc++.h>
using namespace std;
int A[3];
int main() {
  int N, M;
  cin >> N >> M;
  int Si, Ci;
  for (int k = 0; k < M; k++) {
    cin >> Si >> Ci;
    A[Si - 1] = Ci;
  }
  string nums;
  if (A[0] <= 0)
    cout << -1;
  else {
    for (int i = 0; i < N; i++) {
      int k = A[i];
      string klk = to_string(k);
      nums += klk;
    }
    int res = stoi(nums);
    if (res >= 0)
      cout << res;
    else
      cout << -1;
  }
  return 0;
}
