N, M = map(int, input().split())
dn = [[int(n) for n in input().split()] for _ in range(M)]

for i in range(0, 10**N):
	if len(str(i)) == N:
		b = True
		for j in range(M):
			if str(i)[dn[j][0]-1] != str(dn[j][1]):
 				b = False
		if b:
			print(i)
			break
else:
	print(-1)