n,m = gets.split.map &:to_i
ss = []

m.times{
	s,c = gets.split.map &:to_i
	if ss[s] == nil || ss[s] == c then
		ss[s] = c
	else
		puts '-1'
		exit
	end
}

if n != 1 && ss[1] == 0 then
	puts '-1'
else
	result = ''
	(1..n).each{ |i|
		if ss[i] == nil then
			if i == 1 then
				result += '1'
			else
				result += '0'
			end
		else
			result += ss[i].to_s
		end
	}
	puts result
end
