#include <bits/stdc++.h>
using namespace std;
const int MN = 100005, inf = 1000000005, mod = 1000000007;
const long long INF = 1000000000000000005LL;
vector<long long> res;
long long gcd(long long a, long long b) {
  while (a && b) {
    if (a > b) {
      res.push_back(a / b);
      a %= b;
    } else {
      res.push_back(-(b / a));
      b %= a;
    }
  }
  return a + b;
}
int main() {
  long long a, b;
  scanf("%lld%lld", &a, &b);
  long long x = gcd(a, b);
  if (x > 1LL) {
    printf("Impossible");
    return 0;
  }
  if (res.back() > 0LL)
    res.back()--;
  else
    res.back()++;
  for (auto x : res)
    if (x > 0LL)
      printf("%lldA", x);
    else
      printf("%lldB", -x);
}
