#include <bits/stdc++.h>
using namespace std;
long long a, b;
long long gcd(long long x, long long y) { return (y == 0) ? x : gcd(y, x % y); }
int main() {
  while (scanf("%I64d%I64d", &a, &b) != EOF) {
    if (gcd(a, b) != 1) {
      cout << "Impossible\n";
    } else {
      while (a && b) {
        if (a > b) {
          long long time = a / b;
          if (b * time == a)
            printf("%I64dA", time - 1);
          else
            printf("%I64dA", time);
          a -= time * b;
        } else {
          long long time = b / a;
          if (a * time == b)
            printf("%I64dB", time - 1);
          else
            printf("%I64dB", time);
          b -= time * a;
        }
      }
      cout << endl;
    }
  }
  return 0;
}
