package main
import (
"fmt"
"strconv"
)
func gcd(a, b int64) int64 {
for b != 0 {
a, b = b, a%b
}
return a
}
func main() {
var x, y int64
if _, err := fmt.Scan(&x, &y); err != nil {
return
}
if gcd(x, y) != 1 {
fmt.Println("Impossible")
return
}
var result string
for x > 0 && y > 0 {
if x > y {
count := x / y
if y == 1 {
count--
}
result += strconv.FormatInt(count, 10) + "A"
x %= y
} else if y > x {
count := y / x
if x == 1 {
count--
}
result += strconv.FormatInt(count, 10) + "B"
y %= x
} else {
break
}
}
fmt.Println(result)
}