#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)

void solve() {
  int n, m;
  std::cout >> n >> m;
  std::vector<std::pair<int, int> > c(m);
  // first:s second:c
  rep(i,m) std::cin >> c[i].first >> c[i].second;
  rep(x, std::pow(10, n-1) {
    std::vector<int> d(1, x%10);
    int nx = x / 10;
    while (nx) {
      d.push_back(nx%10);
      nx /= 10;	
    }
    std::reverse(d.begin(), d.end());
    if (d.size() != n) continue;
    bool ok = true;
    rep(i,m) if (d[c[i].first-1] != c[i].second) ok = false;
    if (ok) {
      std::cout << x << std::endl;
      return;
    }
  }
  std::cout << -1 << std::endl;
  return;
}

int main() {
  solve();
  return 0;
}