#include <bits/stdc++.h>
using namespace std;
long long x, y;
long long p[1000086];
string st, r = "Impossible";
long long sxqn(long long a, long long b) {
  if (a == 1 && b == 1) {
    char c = st[0];
    for (int i = 0; i < st.size(); i++) cout << p[i] << st[i];
    exit(0);
  }
  if (a == b) {
    cout << r;
    exit(0);
  }
  if (a < b) {
    long long c, d;
    c = b / a;
    d = b % a;
    if (d == 0) {
      if (a == 1)
        c--;
      else {
        cout << r;
        exit(0);
      }
      d = 1;
    }
    b = d;
    long long l = st.size();
    if (st[l - 1] != 'B') {
      st += 'B';
      p[l] += c;
    } else
      p[l - 1] += c;
  }
  if (a > b) {
    long long c, d;
    c = a / b;
    d = a % b;
    if (d == 0) {
      if (b == 1)
        c--;
      else {
        cout << r;
        exit(0);
      }
      d = 1;
    }
    a = d;
    long long l = st.size();
    if (st[l - 1] != 'A') {
      st += 'A';
      p[l] += c;
    } else
      p[l - 1] += c;
  }
  sxqn(a, b);
}
int main() {
  st = "";
  cin >> x >> y;
  sxqn(x, y);
  return 0;
}
