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)

cond = 0
flg = [0] * N
ans = ['a'] * N
for i in range(M):
	if flg[s[i]-1] == 1:
		if str(c[i]) != ans[s[i]-1]:
			cond = 1
			break
	else:
		ans[s[i]-1] = str(c[i])
		flg[s[i]-1] = 1

if ans[0] == '0':
	cond = 1

if cond:
	print(-1)
	sys.exit()

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

print(''.join(ans))