a = $<.map(&:to_i) b = [0,1,2].sort_by{|i|a[i]}.reverse puts b.map{|x|"ABC"[x]}