#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, s;
  char c;
  string ans;
  cin >> N >> M;
  if (N == 1) ans = "A";
  if (N == 2) ans = "AA";
  if (N == 3) ans = "AAA";
  for (int i = 0; i < M; i++) {
    cin >> s >> c;
    if (ans.at(s - 1) != 'A' && ans.at(s - 1) != c) {
      ans = "-1";
      break;
    }
    ans.at(s - 1) = c;
  }
  if (ans.at(0) == '0') ans = "-1";
  if (ans.at(0) == 'A') ans.at(0) = '1';
  if (ans != "-1") {
    for (int i = 0; i < N; i++) {
      if (ans.at(i) == 'A') ans.at(i) = '0';
    }
  }
  cout << ans << endl;
}
