#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    bool ok = 1;
    int n, m, index;
    char x;
    cin>>n>>m;
    string num = "";
    loop(n) num.push_back('0');
    num[0] = '1';

    loop(m){
        cin>>index>>x;
        if(index != 1 && num[index-1] != '0') ok = 0;
        else(num[index-1] = x;)
    }

    if(n==1 && num=="0"){
        cout<<0<<"\n";
        return 0;
    }

    if(!ok || num[0]=='0') cout<<-1<<"\n";
    else cout<<num<<"\n";
    return 0;
}