gets c1 = c2 = 0 gets.split.each do |s| case s.to_i when 1 c1 += 1 when 2 c2 += 1 else puts "B" exit end end if c2 > 1 || (c1 + 2 * c2)%2 == 0 puts "B" else puts "A" end