#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a > b) return gcd(b, a);
  if (a == 0) return b;
  return gcd(b % a, a);
}
string s;
int main() {
  long long x, y;
  cin >> x >> y;
  if (gcd(x, y) != 1) {
    cout << "Impossible\n";
    return 0;
  }
  while (x > 1 && y > 1) {
    if (x > y) {
      cout << x / y << "A";
      x = x % y;
    } else {
      cout << y / x << "B";
      y = y % x;
    }
  }
  if (y == 1)
    cout << x - 1 << "A";
  else
    cout << y - 1 << "B";
  cout << endl;
  return 0;
}
