#include <bits/stdc++.h>
using namespace std;
vector<pair<string, long long>> av;
string ans;
bool ok;
long long gcd(long long a, long long b) {
  pair<long long, long long> x = minmax(a, b);
  if (x.first == 0) {
    if (x.second == 1) {
      ok = true;
      return 1;
    } else {
      ok = false;
      return x.second;
    }
  }
  if (a > b) {
    av.push_back(make_pair("A", a / b));
    return gcd(a % b, b);
  } else {
    av.push_back(make_pair("B", b / a));
    return gcd(a, b % a);
  }
}
int main() {
  long long x, y;
  cin >> x >> y;
  ok = false;
  gcd(x, y);
  if (av.size() > 0) {
    av[av.size() - 1].second--;
  }
  for (auto z : av) {
    stringstream ss;
    ss << z.second;
    ans += ss.str() + z.first;
  }
  if (ok && !ans.empty())
    cout << ans;
  else
    cout << "Impossible";
  return 0;
}
