#include <iostream>

using namespace std;
int a[5];
int main(int argc, char *argv[]) {
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;++i){
		int s,c;
		cin>>s>>c;
		if(a[s]&&a[s]!=c){
			cout<<-1<<endl;
			return 0;
		}
		if(n!=1&&s==1&&c==0) {cout<<-1<<endl; return 0;}
		a[s]=c;
	}
	if(a[1]==0&&n==1) cout<<a[1]<<endl;
	else if(a[1]==0) {
		cout<<1;
		for(int i=2;i<=n;++i)
			cout<<a[i];
		cout<<endl;
	}
	else {
		for(int i=1;i<=n;++i)
			cout<<a[i];
		cout<<endl;
	}
	return 0;
}