require 'date'

timetables = Array.new
2.times do
  timetables << ((STDIN.gets).split).map { |i| i.to_i }
end

a1 = Array.new
timetables.each do |t|
  a1 << t[1..-1]
end

a2 = Array.new
a1.flatten.each_slice(2) do |i|
  a2 << DateTime.parse(i.join(':'))
end

print "#{a2.sort.map{|i| i.strftime("%H:%M")}.join(' ')}\n"