#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<int> S(M);
  vector<int> C(M);
  for (int i = 0; i < M; ++i) {
    cin >> S[i] >> C[i];
  }
  int ans = pow(10, N - 1);
  int a_max = pow(10, N) - 1;
  for (; ans < a_max; ans++) {
    int ok = 1;
    string num = to_string(ans);
    for (int i = 0; i < M; ++i) {
      if (num[S[i] - 1] != C[i] + '0') {
        ok = 0;
      }
    }
    if (ok) {
      break;
    }
  }
  if (ans == a_max) ans = -1;
  cout << ans;
  return 0;
}
