#include <bits/stdc++.h>
using namespace std;
auto f = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
};
int main() {
  f();
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > d;
  while (m--) {
    int idx, nm;
    cin >> idx >> nm;
    d.push_back({idx, nm});
  }
  for (int i = 0; i < 1000; ++i) {
    string s = to_string(i);
    if (s.size() == n) {
      bool ok = false;
      for (size_t j = 0; j < d.size(); ++j) {
        if ((s[d[j].first - 1] - '0') == d[j].second) ok = true;
      }
      if (ok) {
        cout << s << "\n";
        return 0;
      }
    }
  }
  cout << -1 << "\n";
  return 0;
}
