import sys

N, M = map(int, input().split())
s,c = [],[]
for _ in range(M):
	ts,tc = map(int, input().split())
	s.append(ts)
	c.append(tc)

ans = [-1] * N

for i in range(M):
	ind = s[i]-1
	num = c[i]

	if ans[ind] == -1:
		ans[ind] = num
	else:
		if ans[ind] != num:
			print(-1)
			sys.exit()

if ans[0] == 0:
	print(-1)
	sys.exit()

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

print(''.join(list(map(str, ans))))