#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
vector<pair<long long, long long> > ans;
void solve() {
  long long x, y;
  cin >> x >> y;
  if (gcd(x, y) != 1) {
    cout << "Impossible\n";
    return;
  }
  char a = 'A', b = 'B';
  while (true) {
    if (x == 1 && y == 1) break;
    if (x > y) {
      long long k = (x - 1) / y;
      cout << k << a;
      x -= k * y;
    } else {
      swap(a, b);
      swap(x, y);
    }
  }
}
int main() {
  solve();
  return 0;
}
