#include <bits/stdc++.h>
using namespace std;
const int iinf = 1e9 + 10;
const long long inf = 1ll << 60;
const long long mod = 1e9 + 7;
void GG() {
  cout << "Impossible\n";
  exit(0);
}
long long mpow(long long a, long long n, long long mo = mod) {
  long long re = 1;
  while (n > 0) {
    if (n & 1) re = re * a % mo;
    a = a * a % mo;
    n >>= 1;
  }
  return re;
}
long long inv(long long b, long long mo = mod) {
  if (b == 1) return b;
  return (mo - mo / b) * inv(mo % b, mo) % mo;
}
const int maxn = 1e6 + 5;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long a, b;
  cin >> a >> b;
  vector<pair<long long, long long> > re;
  while (a != 1 || b != 1) {
    if (a == b) {
      GG();
    }
    if (a > b) {
      long long tk = (a - 1) / b;
      re.push_back({tk, 0});
      a -= tk * b;
    } else {
      long long tk = (b - 1) / a;
      re.push_back({tk, 1});
      b -= tk * a;
    }
  }
  for (int i = 0; i < (int)re.size(); ++i) {
    cout << re[i].first << (re[i].second ? 'B' : 'A');
  }
}
