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