n,m = map(int,input().split())
ans_value = ['1'] + ['0'] * (n - 1)
check_sum = [0] * n
exist = True

for i in range(m):
	s,c = input().split()
	s = int(s)
	if not ans_value[s-1] == c:
		check_sum[s-1] += 1
	ans_value[s-1] = c
	if check_sum[s-1] >= 2:
		exist = False
if n > 1:
	if exist and not(ans_value[0] == '0'):
		print(''.join(ans_value))
	else:
		print(-1)
elif m == 0:
	print(0)
else:
	print(''.join(ans_value))
