import collections

n,m = map(int,raw_input().split(' '))
res = [-1] * n
flag = True
for _ in range(m):
	s,c = map(int, raw_input().split(' '))

	if res[s] == -1:
		res[s] = c
	else:
		flag = False

if flag is True:
	found = -1
	for i in range(len(s)):
		if s[i] == -1:
			s[i] = 0 if i else 1
	print ''.join(map(str, s))

else:
	print -1
