#include<bits/stdc++.h>

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define mod 1000000007

using namespace std;

int main()
{
	//#ifdef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	std::ios_base::sync_with_stdio(false);

	ll n,m;
	cin>>n>>m;
	ll a[n]={0};
	f(n)
	{
		a[i]=-1;
	}
	f(m)
	{
		ll x,y;
		cin>>x>>y;
		x=x-1;
		if((a[x]==-1)||(a[x]==y))
		{
			a[x]=y;
		}
		else
		{
			cout<<-1;
			return 0;
		}
		if(x>=n)
		{
			cout<<-1;
			return 0;
		}
	}
	if(a[0]==0)
	{
		cout<<-1;
		return 0;
	}
	f(n)
	{
		if(a[i]==-1)
		{
			a[i]=0;
		}
	}
	if(a[0]==0)
	{
		a[0]=1;
	}
	f(n)
	{
		cout<<a[i];
	}
	return 0;
}