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