import sys

n,m = map(int,input().split())
sc = []
for _ in range(m):
	sc.append(list(map(int,input().split())))

sc.sort()
ans = ['0' for _ in range(n)]
ans[0] = '1'
d = {}
for i in range(m):
	if sc[i] == [1,0]:
		print(-1)
		sys.exit()
	if sc[i][0] not in d:
		d[sc[i][0]] = sc[i][1]
	else:
		if d[sc[i][0]] != sc[i][1]:
			print(-1)
			sys.exit()

for i,v in d.items():
	ans[i-1] = str(v)

print("".join(ans))
