#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15) + 10;
const ld EPS = 1e-10;
const int MOD = int(1e9) + 7;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> S(M), C(M);
  for (int i = int(0); i < int(M); i++) cin >> S[i] >> C[i];
  for (int k = int(ll(pow(10, N - 1))); k < int(ll(pow(10, N))); k++) {
    bool f = true;
    for (int i = int(0); i < int(M); i++) {
      if (to_string(k).size() < S[i]) f = false;
      if (to_string(k)[S[i] - 1] - '0' != C[i]) f = false;
    }
    if (f) {
      cout << k << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
