N, M = gets.split.map(&:to_i)
str = "0" * N
str[0] = "1"

M.times do |i|
  s,c = gets.split.map(&:to_i)
  str[s-1] = c.to_s
end

val = str.to_i
ret = val.to_s
if ret.length != N
  puts "-1"
else
  puts ret
end
