n, m = map(int, input().split())

A = [-1] * n

for i in range(m):
	s, c = map(int, input().split())
	if A[s-1] == c:
		continue
	if A[s-1] != -1 or (s == 1 and c == 0):
		print(-1)
		exit()
	A[s-1] = c
print(1 if A[0] == -1 else A[0], end='')
for a in A[1:]:
	print(0 if a == -1 else a, end='')