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