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