#include <bits/stdc++.h>
using namespace std;
long long x, y;
long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; }
int main() {
  scanf("%I64d%I64d", &x, &y);
  if (gcd(x, y) != 1) return puts("Impossible"), 0;
  int t = 1;
  while (x != y) {
    if (x > y) {
      swap(x, y);
      t = !t;
    }
    printf("%I64d%c", (y - 1) / x, "AB"[t]);
    y = 1 + (y - 1) % x;
  }
}
