N,M=map(int,input().split())                            # 1行2列
List=[list(map(int,input().split())) for i in range(M)] # N行C列・・・Cは任意


if N == 1:
	answer = ' '
elif N == 2:
	answer = '  '
elif N == 3:
	answer = '   '

ok = 0
for search in List:
	# search[0]:桁数
	# search[1]:値
	if answer[search[0]-1] == str(search[1]) or answer[search[0]-1] == ' ':
		anslist = list(answer)
		anslist[search[0]-1] = str(search[1])
		answer = ''.join(anslist)
	else:
		ok = -1
		break

if N != 1 and (answer[0] == ' ' or answer[0] == '0'):
	ok = -1

if ok == -1:
	print(-1)
else:
	for i in range(N):
		if answer[i] == ' ':
			anslist = list(answer)
			anslist[i] = '0'
			answer = ''.join(anslist)
	print(answer)
