# Track and Field Competition

a1=Array.new()
a2=Array.new() #finalist
a3=Array.new()

24.times { |i|
  n, t=gets.split.map(&:to_f)
  a1<<[n, t]
  if i%8==7
    a1.sort_by! { |item| item[1] }
    a2=a2+a1[0..1]
    a3=a3+a1[2..-1]
    a1.clear
  end
}

a3.sort_by! { |item| item[1] }
a2=a2+a3[0..1]

a2.each { |each|
  puts "#{each[0].to_i} #{each[1]}"
}