#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  char ans[n];
  
  rep(i,m) {
    int s;
    char c;
    cin >> s >> c;
    if(a[s] == '/0') {
      a[s] = c;
    } else if(a[s] != 'c') {
      cout << -1 << endl;
      return 0;
    }
  rep(i,n) {
    if(a[i] == '/0') a[i] = '0';
  }
    
  cout << a << endl;  
  
  
}