#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(M), B(M);
  for (long long i = (long long)(0); i < (long long)(M); i++)
    cin >> A[i] >> B[i];
  long long ans = -1;
  for (long long i = (long long)(pow(10, (N - 1))); i < (long long)(pow(10, N));
       i++) {
    string S = to_string(i);
    bool flag = 1;
    for (long long j = (long long)(0); j < (long long)(M); j++) {
      if (S[A[j] - 1] != '0' + B[j]) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}
