#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
int main(){
    int a, b;
    cin>>a>>b;
    int tar[3]={-1, -1, -1};
    int x, y;
    if (b==0){
        int hi=0;
        if (a==2) hi=10;
        if (a==3) hi=100;
        cout<<hi<<endl;
        return 0;
    }
    for (int i=0; i<b; i++){
        cin>>x>>y;
        if (tar[x-1+(3-a)]==-1 || tar[x-1+(3-a)]==y) tar[x-1+(3-a)]=y;
        else {
            cout<<-1<<endl;
            return 0;
        }
    }
    for (int i=0; i<a; i++){
        if (tar[i]!=-1){
            if (3-i>a){
                cout<<-1<<endl;
                return 0;
            }
            int diff=-1;
            if (3-i<a){
                diff=a-(3-i);
                cout<<1, diff--;
                while (diff!=0){
                    cout<<0, diff--;
                }
            }
            if (diff==-1 && tar[i]==0) tar[i]=1; 
            for (int j=i; j<3; j++){
                if (tar[j]==-1) cout<<0;
                else cout<<tar[j];
            }
            cout<<endl;
            return 0;
        }
    }
    else cout<<-1<<endl;
}