#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  ostringstream sout;
  while (!(a == 1 && b == 1)) {
    if (a == 0 || b == 0) {
      cout << "Impossible\n";
      return 0;
    }
    if (a == 1) {
      sout << b - 1 << 'B';
      break;
    } else if (b == 1) {
      sout << a - 1 << 'A';
      break;
    } else {
      if (a < b) {
        long long r = b / a;
        sout << r << 'B';
        b -= a * r;
      } else {
        long long r = a / b;
        sout << r << 'A';
        a -= b * r;
      }
    }
  }
  cout << sout.str() << '\n';
  return 0;
}
