#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, y;
  cin >> x >> y;
  stringstream second;
  while ((x > 1 || y > 1) && x != 0 && y != 0) {
    if (x >= y) {
      if (y == 1) {
        second << x - 1 << 'A';
        x = 1;
      } else {
        second << (x / y) << 'A';
        x = x % y;
      }
    } else {
      if (x == 1) {
        second << y - 1 << 'B';
        y = 1;
      } else {
        second << (y / x) << 'B';
        y = y % x;
      }
    }
  }
  string ans;
  second >> ans;
  if (x == 1 && y == 1) {
    cout << ans << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}
