#include<bits/stdc++.h>
# define ll long long
# define mod 1000000007
using namespace std;
int main()
{
	int n,m,z=-1;
	int a[n]={};
	cin>>n>>m;
	while(m--){
		int x,y;
		cin>>x>>y;
		a[x-1]=y;	
	}
	if(a[0]==0)
	cout<<z;
	else
	for(int i=0;i<n;i++){
		cout<<a[i];
	}
	return 0;
}