#include<bits/stdc++.h>

using namespace std;
int a[8];
int main()
{
    memset(a,-1,sizeof(a));
    int n,m;cin>>n>>m;
    int x,y;
    while(m--)
    {
        cin>>x>>y;
        if(a[x]!=-1&&a[x]!=y) return cout<<"-1",0;
        a[x]=y;
    }
    if(n!=1&&a[1]==0) return cout<<"-1",0;
    if(a[1]==-1) a[i]==1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=-1) cout<<a[i];
        else if(n==1||i!=1) cout<<0;
    }
}
