#include <bits/stdc++.h>
using namespace std;
long long int u[1000005];
char s[1000005];
int main(void) {
  long long int x, y;
  scanf("%I64d%I64d", &x, &y);
  int r = 0;
  int QQ = 0;
  while (!(x == 1 && y == 1)) {
    if (x == 0 || y == 0) {
      QQ = 1;
      break;
    }
    if (x > y) {
      long long int t = x / y;
      if (y == 1) t--;
      x -= t * y;
      u[r] = t;
      s[r++] = 'A';
    } else if (x < y) {
      long long int t = y / x;
      if (x == 1) t--;
      y -= t * x;
      u[r] = t;
      s[r++] = 'B';
    } else {
      QQ = 1;
      break;
    }
  }
  if (QQ)
    printf("Impossible\n");
  else {
    for (int i = 0; i < r; i++) {
      printf("%I64d%c", u[i], s[i]);
    }
    printf("\n");
  }
  return 0;
}
