import sys
n, m = list(map(int, input().split()))
res = [list(map(int, input().split())) for _ in range(m)]

ans = [-1 for _ in range(n)]

if n == 1 and m == 1 and res[0][0] == 1 and res[0][1] == 0:
	print(0)
	sys.exit()

for r in res:
	if ans[r[0] - 1] >= 0:
		if ans[r[0] - 1] != r[1]:
			print(-1)
			sys.exit()
	ans[r[0] - 1] = r[1]

#print(res)
#print(ans)
flag = 0
for i in range(n):
	if ans[i] == -1:
		if flag:
			ans[i] = 0
		else:
			ans[i] = 1
	if i == 0 and ans[i] == 0:
		print(-1)
		sys.exit()
	else:
		flag = 1


print("".join([str(a) for a in ans]))