#include<iostream>
using namespace std;
#define ll long long

int main()
{
	int n,m;cin>>n>>m;
	int arr[n+1]={0};
	while(m--)
	{
		int a,b;cin>>a>>b;
		arr[a]=b;
	}
	if(arr[1]==0)
	cout<<-1;
	else
	{
		for(int i=1;i<=n;i++)
		cout<<arr[i];
	}
}
