round = Array.new
round[0] = Hash::new
round[1] = Hash::new
round[2] = Hash::new
final = Hash::new

#get input
for j in 0...3
  for i in 0...8
    input = gets.split(" ")
    round[j][input[0]] = input[1]
  end
end

#ソートのために配列化
r1 = round[0].to_a
r2 = round[1].to_a
r3 = round[2].to_a

#タイムでソート
r1.sort!{|rec1, rec2|  rec1[1]<=>rec2[1]}
r2.sort!{|rec1, rec2|  rec1[1]<=>rec2[1]} 
r3.sort!{|rec1, rec2|  rec1[1]<=>rec2[1]}
  
#各ラウンド上位2位を決勝候補に追加
print(r1[0][0], " ", r1[0][1], "\n")
print(r1[1][0], " ", r1[1][1], "\n")
r1.delete_at(0)
r1.delete_at(0)

print(r2[0][0], " ", r2[0][1], "\n")
print(r2[1][0], " ", r2[1][1], "\n")
r2.delete_at(0)
r2.delete_at(0)

print(r3[0][0], " ", r3[0][1], "\n")
print(r3[1][0], " ", r3[1][1], "\n")
r3.delete_at(0)
r3.delete_at(0)

#残りの配列を結合してソートして上位2位取得
rest = r1.concat(r2).concat(r3)
rest.sort!{|rec1, rec2|  rec1[1]<=>rec2[1]}
print(rest[0][0], " ", rest[0][1], "\n")
print(rest[1][0], " ", rest[1][1], "\n")
