a=[];3.times{h,w=gets.split.map &:to_i;a<<h*101-w};a=a.zip(%w(A B C)).sort.reverse;a.map{|x|puts x[1]}