#include <bits/stdc++.h>
int const MOD = 1e9 + 7;
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> pos(m);
  for (auto &i : pos) cin >> i.first >> i.second;
  for (int i = 1; i < 1000; i++) {
    string s = to_string(i);
    if (s.size() != n) continue;
    bool ok = true;
    for (auto it : pos) {
      if (s[it.first - 1] - '0' != it.second) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << s << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
}
