#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int res = -1;
  int s[m];
  char c[m];
  for (int j = 0; j < m; j++) {
    cin >> s[j] >> c[j];
  }
  for (int i = pow(10, n - 1); i < pow(10, n); i++) {
    string number = to_string(i);
    bool p = true;
    for (int j = 0; j < m; j++) {
      if (number.at(s[j] - 1) != c[j]) {
        p = false;
        break;
      }
    }
    if (p) {
      res = i;
      break;
    }
  }
  cout << res << endl;
  return 0;
}
