def make_route a, b
    arr = [[0,0,""]]
    route = []
    until arr.empty?
        x, y, z = arr.shift
        arr << [x+1, y, z+"A"] if x < a && y != 5
        arr << [x, y+1, z+"B"] if y < b && x != 5
        route << z if x == a && y == b
    end
    return route
end

a, b = gets.chomp.split.map(&:to_i)

case [a, b]
when [6, 4]
    route = make_route(5, 4)
    route.map!{|r| r + "A"}
when [4, 6]
    route = make_route(4, 5)
    route.map!{|r| r + "B"}
when [5, 5]
    route = []
    route2 = make_route(4, 4)
    route2.each{|r|
        route << r + "AB"
        route << r + "BA"
    }
else
    route = make_route(a, b)
end
route.sort!
puts route
