#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m), c(m);
  for (int i = 0; i < (m); ++i) cin >> s[i] >> c[i];
  for (int i = 1; i < 1000; ++i) {
    string t = to_string(i);
    if (t.size() != n) continue;
    bool elf = true;
    for (int i = 0; i < (m); ++i) {
      if (t[s[i] - 1] != char(c[i] + '0')) elf = false;
    }
    if (elf) {
      cout << t << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
