#include <bits/stdc++.h>
using namespace std;
long long x, y;
int main() {
  cin >> x >> y;
  ostringstream oss;
  while (x != 1 || y != 1) {
    if (x < y) {
      oss << (y - 1) / x << 'B';
      y = (y - 1) % x + 1;
    } else if (x > y) {
      oss << (x - 1) / y << 'A';
      x = (x - 1) % y + 1;
    } else {
      cout << "Impossible\n";
      return 0;
    }
  }
  cout << oss.str() << '\n';
  return 0;
}
