#include <bits/stdc++.h>
using namespace std;
const long double pi = 2 * acos(0.0);
const long long prime = 31;
;
const long long inf = 1e18;
const long long mod = 1e18;
const long long maxn = 2e5 + 11;
const long long dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long long dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};
long long x, y, cnt;
bool k;
string ans;
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> x >> y;
  if (gcd(x, y) != 1) {
    cout << "Impossible";
    return 0;
  }
  k = (x <= y);
  while (x > 1 || y > 1) {
    if (x > y) {
      if (k == 1) {
        cout << cnt << 'B';
        cnt = 0;
        k = 0;
      }
      cnt += x / y;
      x %= y;
    } else {
      if (k == 0) {
        cout << cnt << 'A';
        cnt = 0;
        k = 1;
      }
      cnt += y / x;
      y %= x;
    }
  }
  if (k == 0)
    cout << cnt - 1 << 'A';
  else
    cout << cnt - 1 << 'B';
  return 0;
}
