import sys
input = sys.stdin.readline

N, M = map(int, input().split())
num = [1] * N
seen = {}
for i in range(M):
	s, c = map(int, input().split())
	if s in seen:
		if seen[s] != c:
			print(-1)
			exit()
	if s == 1 and c == 0:
		if N == 1:
			print(0)
			exit()
		else:
			print(-1)
			exit()
	num[s-1] = c
	seen[s] = c
print(int(''.join(map(str, num))))


