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

    char ans[N] = {};
    for(int i=0;i<N;i++){
        ans[i] = 'x';
    }

    for(int i=0;i<M;i++){
        if(ans[s[i]-1] == 'x'){
            ans[s[i]-1] = c[i];
        }else if(ans[s[i]-1] != c[i]){
            cout << -1 << endl;
            return 0;
        }
    }

    for(int i=0;i<N;i++){
        if(ans[i] != 'x'){
            cout << ans[i];
        }else if(i == 0){
            cout << 1;
        }else{
            cout << 0;
        }
        
    }

    cout << endl;

}