n, m = map(int, input().split())
ans = [1] + [0] * (n - 1)
seen = {}
flag = False
for _ in range(m):
	s, c = map(int, input().split())
	if seen.get(s, False) and seen[s] != c:
		flag = True
		break
	seen[s] = c
	ans[s - 1] = c
ans = int(''.join(map(str, ans)))
if flag or len(str(ans)) != n:
	print(-1)
else:
	print(ans)
