#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const long long BIG = 1000000007;
const double PI = 3.141592653589793;
int main() {
  int n, m;
  cin >> n >> m;
  string str(n, 'a');
  for (int i = 0; i < (m); i++) {
    int s;
    char c;
    cin >> s >> c;
    if (s > n) {
      cout << "-1" << endl;
      return 0;
    }
    if (str[s - 1] == 'a') {
      str.replace(s - 1, 1, 1, c);
    } else {
      continue;
    }
  }
  for (int i = 0; i < (n); i++) {
    if (str[i] == 'a') str.replace(i, 1, 1, '0');
  }
  if (str[0] == '0') {
    cout << "-1" << endl;
    return 0;
  }
  cout << str << endl;
  return 0;
}
