n, m = [int(i) for i in input().split()]
ans = [10 for i in range(n)]

for i in range(m):
	s, c = [int(j) for j in input().split()]
	if s == 1 and c == 0:
		print("-1")
		break
	elif ans[s-1] != 10 and c != ans[s-1]:
		print("-1")
		break
	else:
		ans[s-1] = c
else:

	for i, num in enumerate(ans):
		if num == 10 and i == 0:
			print(1, end = "")
		elif num == 10:
			print(0, end="")
		else:
			print(num, end ="")
	print()



