#include <bits/stdc++.h>
using namespace std;
const int N = 4007;
const int M = 100;
const int inf = (int)1e9 + 7;
const long long base = (long long)1e18;
const double pi = acos(-1);
const double ep = 1e-18;
long long gcd(long long a, long long b) { return (a == 0) ? b : gcd(b % a, a); }
string ans = "";
void solve() {
  long long a, b;
  cin >> a >> b;
  if (gcd(a, b) > 1) {
    puts("Impossible");
  } else {
    while (!(a == 1 && b == 1)) {
      if (a > b) {
        long long k = a / b;
        if (b == 1) k--;
        a -= k * b;
        cout << k << 'A';
      } else {
        long long k = b / a;
        if (a == 1) k--;
        b -= k * a;
        cout << k << 'B';
      }
    }
  }
}
int main() {
  solve();
  return 0;
}
