n,m=map(int,input().split())
flag=1
arr=[-1 for i in range(n)]
#print(n,m)
#print(arr)
for i in range(m):
	s,c=map(int,input().split())
	print(s,c)
	if arr[s-1]!=-1:
		if arr[s-1]!=c:
			flag=0
		else:
			flag=1
	else:
		arr[s-1]=c
if flag==0:
	print(-1)
else:
	for i in range(n):
		if(arr[i]==-1):
			print(1,end="")
		else:
			print(arr[i],end="")