import sys
n,m = (int(i) for i in input().split())
number = [0] * n
numberFlag = [0] * n
answer = ""
if m == 0:
	if n > 1:
		print(10 ** (n-1))
		exit(0)
	else:
		print(-1)
		exit(0)
for i in range(m):
	s,c = (int (i) for i in input().split())
	if s == 1 and c == 0 and n > 1:
		print(-1)
		exit(0)
	elif number[s-1] != c and numberFlag[s-1] == 1:
		print(-1)
		exit(0)
	elif numberFlag[s-1] == 0:
		number[s-1] = c
		numberFlag[s-1] = 1

for i in range(n):
	answer += str(number[i])
print(answer)