Shop = "ABCDE"
N = Shop.length

until (data = [gets.chomp]) == ["0 0"]
  data.concat((N - 1).times.map {gets})
  result = data.map.with_index {|d, i| [d.split.map(&:to_i).sum, i]}.sort.last
  puts "#{Shop[result[1]]} #{result[0]}"
end
