### main

ws = 10.times.map{gets.strip.to_i}
ks = 10.times.map{gets.strip.to_i}

w_score = ws.sort{|a, b| b <=> a}[0..2].inject(:+)
k_score = ks.sort{|a, b| b <=> a}[0..2].inject(:+)

puts [w_score, k_score].join(' ')