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