# M 0 �` 5
# N 1 �` 3

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

if M == 0
 puts "-1"
 exit
end

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
