#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define forn(i,n) for(ll i=0;i<(n);i++)
#define maxx ((ll)1e6+5)
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int a[n]={-1};
	if(n==1&&m==0)
	a[0]=0;
	set<int>s;
	while(m--)
	{
		int u,v;
		cin>>u>>v;
		if(u>n)
		{
			cout<<"-1";return 0;
		}
		if(u==1&&v==0)
		{
			cout<<"-1";return 0;
		}
		if(s.count(u)==1&&a[u-1]!=v){
		cout<<"-1";return 0;}
		s.insert(u);
		a[u-1]=v;
	}
	forn(i,n)
	{
		if(a[i]==-1)
		{
			if(i==0)
			a[i]=1;
			else
			a[i]=0;
		}
	}
	forn(i,n)
	cout<<a[i];
}