#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pii> p(m);
  for (int i = (0); i < (m); i++) {
    cin >> p[i].first >> p[i].second;
    p[i].first--;
  }
  int s = n == 1 ? 0 : pow(10, n - 1);
  int e = pow(10, n);
  for (int i = (s); i < (e); i++) {
    string is = to_string(i);
    bool ok = true;
    for (auto x : p) {
      if (is[x.first] != x.second) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << (i) << '\n';
      return 0;
    }
  }
  cout << (-1) << '\n';
  return 0;
}
