time = []
result = []
ut = []
3.times do
  time = []
  8.times { time << gets.split.map(&:to_f) }
  temp = time.sort_by{ |t| t.last }
  result << temp[0,2]
  ut << temp[2,2]
end
result << ut.flatten(1).sort_by{ |t| t.last }[0,2]
result.flatten(1).each{ |t| puts "#{t.first.to_i} #{t.last}"}