#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    a ^= b, b ^= a, a ^= b;
  }
  return a;
}
int main() {
  long long a, b;
  scanf("%I64d%I64d", &a, &b);
  if (gcd(a, b) > 1)
    puts("Impossible");
  else {
    while (a && b) {
      if (a > b) {
        printf("%I64dA", a / b - (b == 1));
        a %= b;
      } else {
        printf("%I64dB", b / a - (a == 1));
        b %= a;
      }
    }
  }
  return 0;
}
