#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
typedef long long ll;

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

int main(){
    int n, m;
    cin >> n >> m;
    string str(n, 'a');
    rep(i,m){
        int s;
        char c;
        cin >> s >> c;
        if(s>n){
            cout << "-1" << end;
            return 0;
        }
        if(str[s-1]=='a'){
            str.replace(s-1, 1, 1, c);
        }else{
            continue;
        }
    }
    rep(i,n){
        if(str[i]=='a') str.replace(i, 1, 1, '0');
    }
    if(str[0]=='0'){
        cout << "-1" << endl;
        return 0;
    }
    cout << str << endl;
    return 0;
}