#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  ll N, M;
  cin >> N >> M;
  ll X = 1;
  for (ll i = 0; i < (N); ++i) X *= 10;
  --X;
  vector<ll> s(M), c(M);
  for (ll i = 0; i < (M); ++i) cin >> s[i] >> c[i];
  for (int i = X / 10 + 1; i <= X; ++i) {
    string XX = to_string(i);
    bool flag = true;
    for (ll j = 0; j < (M); ++j) {
      flag = flag && XX[s[j] - 1] - '0' == c[j];
    }
    if (flag) {
      cout << (i) << '\n';
      return 0;
    }
  }
  cout << (-1) << '\n';
  return 0;
}
