#include <bits/stdc++.h>
using namespace std;
template <class T>
string toString(T n) {
  ostringstream ost;
  ost << n;
  ost.flush();
  return ost.str();
}
int main() {
  int n, m, s, c;
  cin >> n >> m;
  vector<pair<int, int>> v;
  for (int i = 0; i < m; ++i) {
    cin >> s >> c;
    v.push_back(make_pair(s, c));
  }
  for (int x = pow(10, n - 1); x < pow(10, n); ++x) {
    bool ok = true;
    for (int i = 0; i < m; ++i) {
      string y = toString(x);
      if (y[v[i].first - 1] - '0' != v[i].second) {
        ok = false;
      }
    }
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
