#include <bits/stdc++.h>
using namespace std;
pair<pair<long long, long long>, bool> solve(long long a, long long b,
                                             long long c) {
  function<pair<pair<long long, long long>, bool>(long long, long long)> f =
      [&](long long a, long long b) {
        if (a == 0ll) {
          if (c % b == 0ll) {
            return make_pair(make_pair(0ll, c / b), true);
          } else {
            return make_pair(make_pair(0ll, 0ll), false);
          }
        }
        auto res = f(b % a, a);
        long long x = res.first.first;
        long long y = res.first.second;
        return make_pair(make_pair(y - b / a * x, x), res.second);
      };
  return f(a, b);
}
int main() {
  ios::sync_with_stdio(false);
  long long x, y;
  cin >> x >> y;
  auto res = solve(x, y, 1);
  if (!res.second) {
    puts("Impossible");
    return 0;
  }
  long long z = res.first.first;
  long long w = -res.first.second;
  if (z < 0ll || w < 0ll) {
    z += y;
    w += x;
  }
  auto a = make_pair(x - w, y - z);
  auto b = make_pair(w, z);
  vector<pair<long long, bool>> ans;
  bool ab = a < b;
  while (!(a == make_pair(1ll, 0ll) && b == make_pair(0ll, 1ll))) {
    if (!ab) swap(a, b);
    long long d = a.first == 0    ? b.second
                  : a.second == 0 ? b.first
                                  : min(b.first / a.first, b.second / a.second);
    b.first -= d * a.first;
    b.second -= d * a.second;
    ans.emplace_back(d, ab);
    if (!ab) swap(a, b);
    ab = !ab;
  }
  reverse(ans.begin(), ans.end());
  for (auto p : ans) {
    printf("%lld%c", p.first, p.second ? 'A' : 'B');
  }
  puts("");
}
