#include <bits/stdc++.h>
using namespace std;
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template <typename T>
void invec(vector<T>& A) {
  for (T& a : A) cin >> a;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  VI s(M), c(M);
  for (int64_t i = (0); i < (M); ++i) cin >> s[i] >> c[i];
  for (int64_t n = (pow(10, N - 1)); n < (pow(10, N)); ++n) {
    bool ok = true;
    for (int64_t i = (0); i < (M); ++i) {
      if (n / (i64)pow((i64)10, N - 1 - (s[i] - 1)) % 10 != c[i]) ok = false;
    }
    if (ok) {
      cout << n << "\n";
      return 0;
    }
  }
  cout << "-1\n";
  return 0;
}
