#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll power(ll x,ll n)
{
	ll res =1;
	while(n>0)
	{
		if(n%2==1)
	res=res*x;
	x=x*x;
	n=n/2;
	}
	return res;
	
}
int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k,i;
    cin>>n>>k;
    int s[k],c[k];
    for(i=0;i<k;i++)
    cin>>s[i]>>c[i];
    map<int,int>m;
    int flag=0;
    for(i=0;i<k;i++)
    {
    	if(m.find(s[i])==m.end())
    	{
    		m[s[i]]=c[i];
    		
		}
		else
		{
			if(m.find(s[i])->second!=c[i])
			{
				flag=-1;
				break;
			}
			
		}
	}
	if(flag==-1)
	cout<<-1;
	else
	{
		int a[n+1]={0};
		map<int,int>::iterator it;
		if(m.begin()->first==1&&m.begin()->second==0&&n!=1)
		cout<<-1;
		else
		{
			for(it=m.begin();it!=m.end();it++)
			{
				
					a[it->first]=it->second;
				
			}
			for(i=1;i<n+1;i++)
			cout<<a[i];
			
		}
	}
}