#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<P> p;
  for (int i = 0; (i) < (int)(m); i++) {
    int a, b;
    cin >> a >> b;
    p.emplace_back(a, b);
  }
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    string now = to_string(i);
    bool f = true;
    for (int j = 0; (j) < (int)(m); j++) {
      int fst = p[j].first, snd = p[j].second;
      if (now[fst - 1] - '0' != snd) f = false;
    }
    if (f) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1;
}
