N, M = map(int, input().split())

d = [None] * N

for _ in range(M):
	s, c = map(int, input().strip().split())
	d[s - 1] = c

if N > 1 and d[0] == 0:
	print(-1)
else:
	if d[0] == None:
		if N == 1:
			d[0] = 0
		else:
			d[0] = 1
	for i in range(1, N):
		if d[i] == None:
			d[i] = 0
	print("".join(map(str, d)))
