#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
long long N, M, K, H, W, L, R, l, r, u, d, sum, Q;
long long ans;
long long no;
bool b, bb[100001];
string s, t;
int main() {
  cin >> N >> M;
  long long num[5];
  char cc[5], c;
  for (int i = 0; i < M; i++) {
    cin >> num[i] >> cc[i];
  }
  for (int i = 0; i < N; i++) {
    s += 'a';
  }
  for (int i = 0; i < M; i++) {
    if (s[num[i] - 1] == 'a' || s[num[i] - 1] == cc[i]) {
      s[num[i] - 1] = cc[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if (s[0] == '0' && N > 1) {
    cout << -1 << endl;
    return 0;
  }
  if (s[0] == 'a') s[0] == 1;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'a') {
      s[i] = '0';
    }
  }
  cout << s << endl;
  return 0;
}
