N, M = map(int, input().split())
ans = [0 for _ in range(N)]
if N == 1:
	ans[0] = 0
else:
	ans[0] = 1
f = 1
flg = [-1 for _ in range(M + 1)]

for _ in range(M):
	s, c = map(int, input().split())
	if s == 1 and c == 0 and N != 1: 
		f = 0
	if flg[s] != -1 and flg[s] != c:
		f = 0
	else:
		flg[s] = c
		ans[s - 1] = c

if f:
	for a in ans:
		print(a, end = "")
else:
	print(-1)