n,m = gets.chomp.split(' ').map(&:to_i)
arr = Array.new(n,0)
for i in 0..(m - 1)
  s,c = gets.chomp.split(' ').map(&:to_i)
  arr[s-1] = c
end
if arr.join.length == arr.join.to_i.to_s.length
  puts arr.join.to_i
else
  puts -1
end
