#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>
 
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;

    string num="";
    for(int i=0;i<n;i++) num += 'x';

    int s;
    char c;
    for(int i=0;i<m;i++){
        cin >> s >> c;

        if(num[s-1] != 'x' && num[s-1] != c){
            cout << -1 << endl;
            return 0;
        }
        if(n != 1 && s == 1 && c == '0'){
            cout << -1 << endl;
            return 0;
        }

        num[s-1] = c;
    }

    if(n == 0){
        if(num == 'x') cout << 0 << endl;
        else cout << num << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(num[i] == 'x'){
            if(i == 0) num[i] = '1';
            else num[i] = '0';
        }
    }

    cout << num << endl;
    
}