#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;
const ll INF = 1LL << 60;
const double EPS = 1e-10;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> s(m), c(m);
  for (int i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  for (int i = (1); i < (1000); i++) {
    string str = to_string(i);
    if (str.size() != n) continue;
    bool ok = true;
    for (int j = 0; j < (m); ++j) {
      if (str[s[j] - 1] - '0' != c[j]) ok = false;
    }
    if (ok) {
      cout << str << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
