#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string a(n, '0');
  for (int i = 0; i < m; i++) {
    int s;
    char c;
    cin >> s >> c;
    a.at(s - 1) = c;
  }
  if (a.at(0) != '0')
    cout << a << endl;
  else
    cout << "-1" << endl;
}
