n, m = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(m)]
for i in range(10 ** n):
	flag = True
	st = str(i)
	if len(st) != n:
		continue
	for s, c in S:
		if int(st[s - 1]) != c:
			flag = False
			break
	if flag:
		print(int(st))
		break
else:
	print(-1)