#include <bits/stdc++.h>
const int INF = 2e9;
const long long mod = 1e9 + 7;
using namespace std;
void precalc() {}
vector<pair<long long, char>> ans;
void gcd(long long a, long long b) {
  if ((a <= 1) && (b <= 1)) return;
  if (a == 0) {
    if (b != 0) printf("Impossible"), exit(0);
    ans.push_back({b, 'B'});
    return;
  }
  if (b == 0) {
    if (a != 0) printf("Impossible"), exit(0);
    ans.push_back({a, 'A'});
    return;
  }
  if (a > b) {
    ans.push_back({a / b - (b == 1 ? 1 : 0), 'A'});
    a %= b;
    gcd(a, b);
  } else {
    ans.push_back({b / a - (a == 1 ? 1 : 0), 'B'});
    b %= a;
    gcd(a, b);
  }
}
int solve() {
  long long a, b;
  scanf("%I64d%I64d", &a, &b);
  gcd(a, b);
  for (auto it = ans.begin(); it != ans.end(); it++)
    printf("%I64d%c", it->first, it->second);
  return 0;
}
int main() {
  precalc();
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
