N,M = map(int,input().split())
ans = [-1] * N
chk = 0
for i in range(M):
	s,c = map(int,input().split())
	if ans[s-1] < 0:
		ans[s-1] = c
	elif ans[s-1] == c:
		continue
	else:
		chk = -1
for i in range(N):
		if i == 0:
			if ans[i] == -1:
				ans[i] = 1
			elif ans[i] == 0:
				chk = -1
		else:
			if ans[i] == -1:
				ans[i] = 0
if chk == -1:
	print(-1)
else:
	for i in range(N):
		ans[i] = str(ans[i])
	s = "".join(ans)
	print(s)