#include <bits/stdc++.h>
using namespace std;
struct ST {
  int a;
  char b;
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<ST> s(m);
  for (int i = 0; i < m; ++i) {
    cin >> s[i].a >> s[i].b;
  }
  for (int i = pow(10, n - 1); i < pow(10, n); ++i) {
    string t = to_string(i);
    bool ch = true;
    for (int j = 0; j < m; ++j) {
      if (!(t[s[j].a - 1] == s[j].b)) {
        ch = false;
      }
    }
    if (ch) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
