#include <bits/stdc++.h>
using namespace std;
bool gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return (a == 1);
}
int main() {
  long long a, b;
  cin >> a >> b;
  if (!gcd(a, b)) return cout << "Impossible", 0;
  while (a != 1 && b != 1) {
    if (a < b)
      printf("%I64dB", b / a), b %= a;
    else
      printf("%I64dA", a / b), a %= b;
  }
  if (a < b) printf("%I64dB", b - 1);
  if (a > b) printf("%I64dA", a - 1);
  return 0;
}
