shops = "ABCDE"
while true
    scores = [0, 0, 0, 0, 0]
    scores[0] = gets.chomp.split.map(&:to_i).inject(:+)
    break if scores[0] == 0
    1.upto(4){|i| scores[i] = gets.chomp.split.map(&:to_i).inject(:+)}
    puts "#{shops[scores.index(scores.max)]} #{scores.max}"
end

