#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  long long x, y;
  scanf("%lld%lld", &x, &y);
  if (gcd(x, y) != 1) {
    printf("Impossible\n");
    return 0;
  }
  while (x != 1 || y != 1) {
    if (x == 1) {
      printf("%lldB", y - 1);
      y = 1;
    } else if (y == 1) {
      printf("%lldA", x - 1);
      x = 1;
    } else if (x < y) {
      printf("%lldB", y / x);
      y = y % x;
    } else {
      printf("%lldA", x / y);
      x = x % y;
    }
  }
}
