human
Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a letter, either 'A', or the letter 'B'. Then they began to remove the cards one by one from left to right, every time they removed a card with the letter 'A', Alice gave Bob all the fruits she had at that moment and took out of the bag as many apples and as many oranges as she had before. Thus the number of oranges and apples Alice had, did not change. If the card had written letter 'B', then Bob did the same, that is, he gave Alice all the fruit that he had, and took from the bag the same set of fruit. After the last card way removed, all the fruit in the bag were over.

You know how many oranges and apples was in the bag at first. Your task is to find any sequence of cards that Alice and Bob could have played with.

Input

The first line of the input contains two integers, x, y (1 ≤ x, y ≤ 1018, xy > 1) — the number of oranges and apples that were initially in the bag.

Output

Print any sequence of cards that would meet the problem conditions as a compressed string of characters 'A' and 'B. That means that you need to replace the segments of identical consecutive characters by the number of repetitions of the characters and the actual character. For example, string AAABAABBB should be replaced by string 3A1B2A3B, but cannot be replaced by 2A1A1B2A3B or by 3AB2A3B. See the samples for clarifications of the output format. The string that you print should consist of at most 106 characters. It is guaranteed that if the answer exists, its compressed representation exists, consisting of at most 106 characters. If there are several possible answers, you are allowed to print any of them.

If the sequence of cards that meet the problem statement does not not exist, print a single word...

Give me a Python program to find any sequence of cards that Alice and Bob could have played with?
assistant
#Here is Python program to find any sequence of cards that Alice and Bob could have played with.

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

class fraction:
    n, m = 0, 0

    def __init__(self, n, m):
        d = int(gcd(n, m))
        self.n = int(n//d)
        self.m = int(m//d)
    def add(self, tmp):
        return fraction(self.n * tmp.m, self.m * tmp.n)

    def compareTo(self ,tmp):
        a = self.n * tmp.m
        b = self.m * tmp.n

        if a > b:
            return 1
        elif a < b:
            return -1

        return 0

    def sternBrocotAdd(self, tmp):
        return fraction(self.n + tmp.n, self.m + tmp.m);

def run(left, right, result):

    a = left.n
    b = left.m
    p = right.n
    q = right.m
    n = result.n
    m = result.m

    mid = left.sternBrocotAdd(right)
    if mid.compareTo(result) == 0:
        return
    ch = 'Z'
    x = 0
    if mid.compareTo(result) <= 0:
        x = int((b * n - a * m) // (p * m - q * n))
        left = fraction(a + p * x, b + q * x)
        ch = 'A'
        if left.compareTo(result) == 0:
           x -= 1
    else:
        x = int((p * m - q * n) // (b * n - a * m))
        right = fraction(a * x + p, b * x + q)
        ch = 'B'
        if right.compareTo(result) == 0:
           x -= 1

    s = str.format("%d%c"%(x, ch))
    print(s, end="")
    if left.compareTo(result) == 0 or right.compareTo(result) == 0:
        return
    run(left, right, result)

p, q = map(int, input().split())

d = gcd(p, q)
if d == 1:
    result = fraction(p, q)
    right = fraction(1, 0)
    left = fraction(0, 1)
    run(left, right, result)
else:
    print('Impossible')