temp, arr = gets.chomp.split.map(&:to_i), []
n = temp.shift
n.times{|i| arr << [temp[i * 2], temp[i * 2 + 1]]}
temp = gets.chomp.split.map(&:to_i)
n = temp.shift
n.times{|i| arr << [temp[i * 2], temp[i * 2 + 1]]}
arr.sort_by!{|h, m| [h, m]}.uniq!
puts arr.map{|h, m| sprintf("%d:%02d", h, m)}.join(" ")
