#include <bits/stdc++.h>
using namespace std;
const double g = 10.0, eps = 1e-12;
const int N = 100000 + 10, maxn = 1200000 + 10, inf = 0x3f3f3f3f,
          INF = 0x3f3f3f3f3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  long long x, y;
  scanf("%lld%lld", &x, &y);
  if (gcd(x, y) != 1)
    puts("Impossible");
  else {
    while (x > 1 && y > 1) {
      if (x > y) {
        printf("%lldA", x / y);
        x -= (long long)(x / y) * y;
      } else {
        printf("%lldB", y / x);
        y -= (long long)(y / x) * x;
      }
    }
    if (x == 1)
      printf("%lldB\n", y - 1);
    else
      printf("%lldA\n", x - 1);
  }
  return 0;
}
