#include <bits/stdc++.h>
using namespace std;
long long x, y, val = 0, q[1000010];
char d[1000010];
void build(int now, int x, int y) {
  if (x == y) return;
  int mid = (x + y) / 2;
  build(2 * now, x, mid);
  build(2 * now, mid + 1, y);
}
int main() {
  build(1, 1, 1000);
  cin >> x >> y;
  while (1) {
    if (x == y && x > 1) {
      cout << "Impossible";
      return 0;
    }
    if (x == y && x == 1) {
      for (int i = 1; i <= val; i++) {
        cout << q[i] << d[i];
      }
      return 0;
    }
    if (x > y) {
      long long k = (x - 1) / y;
      x -= k * y;
      q[++val] = k;
      d[val] = 'A';
      continue;
    }
    if (x < y) {
      long long k = (y - 1) / x;
      y -= k * x;
      q[++val] = k;
      d[val] = 'B';
      continue;
    }
  }
}
