n,m = gets.split.map(&:to_i)
max = 0
ans = [0,0,0]

m.times do
  s,c = gets.split.map(&:to_i)
  if s > max
    max = s
  end

  if ans[s-1] == 0
    ans[s-1] = c
  end
end


if max < n
  puts "-1"
  exit
end

puts ans.map(&:to_s).join