#include <bits/stdc++.h>
using namespace std;
long long x, y;
string tt(long long a) {
  string ans = "";
  while (a != 0) ans += (a % 10) + '0', a /= 10;
  int p = ans.length();
  for (int i = 0; i * 2 < p; ++i) swap(ans[i], ans[p - i - 1]);
  return ans;
}
int main() {
  cin >> x >> y;
  string s;
  while (x != 1 || y != 1) {
    if (x < y) {
      s += tt((y - 1) / x) + 'B';
      y = (y - 1) % x + 1;
    } else if (x > y) {
      s += tt((x - 1) / y) + 'A';
      x = (x - 1) % y + 1;
    } else {
      cout << "Impossible\n";
      return 0;
    }
  }
  cout << s << '\n';
  return 0;
}
