#include <bits/stdc++.h>
using namespace std;
long long idx[3030];
char s[3030];
int main() {
  long long x, y;
  cin >> x >> y;
  int cnt = 0;
  while (x != y) {
    if (x > y) {
      if (y == 1) {
        idx[cnt] = x - 1;
        s[cnt++] = 'A';
        x = 1;
      } else if (x % y) {
        idx[cnt] = x / y;
        s[cnt++] = 'A';
        x -= idx[cnt - 1] * y;
      } else
        break;
    } else {
      if (x == 1) {
        idx[cnt] = y - 1;
        s[cnt++] = 'B';
        y = 1;
      } else if (y % x) {
        idx[cnt] = y / x;
        s[cnt++] = 'B';
        y -= idx[cnt - 1] * x;
      } else
        break;
    }
  }
  if (x != 1 || y != 1)
    puts("Impossible");
  else {
    for (int i = 0; i < cnt; ++i) cout << idx[i] << s[i];
    puts("");
  }
  return 0;
}
