#include<bits/stdc++.h>
using namespace std;

int n,m;
int ans[10];

int main(){
	memset(ans,-1,sizeof(ans));
	scanf("%d%d",&n,&m);
	while(m--){
		int s,c;
		scanf("%d%d",&s,&c);
		if(ans[s] == -1){
			ans[s] = c;
		} else if(ans[s] != c){
			printf("-1\n");
			return 0;
		}
	}
	if(ans[1] == 0 && n > 1){
		printf("-1\n");
		return 0;
	}
	if(ans[1] == -1) {
		if(n == 1) ans[1] = 0;
		else ans[1] = 1;
	}
	for(int i=1;i<=n;i++){
		if(ans[i] == -1) ans[i] = 0;
		printf("%d",ans[i]);
	}
	printf("\n");
	return 0;
}
