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