#include <bits/stdc++.h>
using namespace std;
long long x, y;
vector<char> A_B;
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
int main() {
  cin >> x >> y;
  if (gcd(x, y) != 1) {
    cout << "Impossible" << endl;
    return 0;
  }
  while (x != 1 && y != 1) {
    if (x > y) {
      A_B.push_back('A');
      x -= y;
    } else {
      A_B.push_back('B');
      y -= x;
    }
  }
  long long counter = 1;
  for (long long i = 0; i < A_B.size(); i++) {
    for (i; i < A_B.size() - 1;) {
      if (A_B[i + 1] == A_B[i]) {
        counter++;
        i++;
      } else
        break;
    }
    cout << counter << A_B[i];
    counter = 1;
  }
  if (x == 1 && y != 1) cout << y - x << 'B';
  if (y == 1 && x != 1) cout << x - y << 'A';
  cout << endl;
  return 0;
}
