import numpy as np 

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

data = np.array([-1 for i in range(N)])

error = 0

if M == 0:
	data[0] = 1
	for i in range(1, N):
		data[i] = 0

	L=[str(a) for a in data]
	L="".join(L)
	print(L)

else:
	for i in range(M):
		x, y = map(int, input().split())
		if data[x-1] != y and data[x-1] >= 0:
			error = 1
		else:
			data[x-1] = y

	for i in range(N):
		if data[i] == -1:
			data[i] = 0

	if error == 1 or (data[0] == 0 and len(data) != 1):
		print(-1)
	else:
		L=[str(a) for a in data]
		L="".join(L)
		print(L)