n,m= map(int,input().split(' '))
arr=[0 for i in range(n)]

im= False
for i in range(m):
	x,y= map(int,input().split(' '))
	if x==1 and y==0:
		im=True
	if arr[x-1]!=-1 and arr[x-1]!=y:
		im=True
	arr[x-1]=y
if arr[0]==0:
	arr[0]=1
if im:
	print(-1)
else:
	print(''.join(str(i) for i in arr))