#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
int main() {
  long long int N, M;
  int a = 1;
  string ans;
  cin >> N >> M;
  if (N == 1)
    ans = "a";
  else if (N == 2)
    ans = "aa";
  else if (N == 3)
    ans = "aaa";
  vector<int> s(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
    if (ans.at(s.at(i) - 1) != 'a' && ans.at(s.at(i) - 1) != ('0' + c.at(i)))
      a = 0;
    ans.at(s.at(i) - 1) = '0' + c.at(i);
  }
  if (N == 1) {
  } else if (N == 2) {
    if (ans.at(0) == 'a') ans.at(0) = '1';
    if (ans.at(1) == 'a') ans.at(1) = '0';
    if (ans.at(0) == '0') a = 0;
  } else if (N == 3) {
    if (ans.at(0) == 'a') ans.at(0) = '1';
    if (ans.at(1) == 'a') ans.at(1) = '0';
    if (ans.at(2) == 'a') ans.at(2) = '0';
    if (ans.at(0) == '0') a = 0;
  }
  if (a == 0)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
