N,M=map(int,input().split())
lines=[]
lines_s=[]
ans=0
for line in range(M):
	s,c=map(int,input().split())
	if N>=s and s not in lines_s:
		ans+=c*(10**(N-s))
		lines.append([s,c])
		lines_s.append(s)
	elif [s,c] in lines:
		continue

	else:
		break

if len(str(ans))==N:
	print(ans)
else:
	print(-1)

