#include <bits/stdc++.h>
using namespace std;
int vis[4001], n;
long long vv[4001], co[4001], dd[4001];
void dfs1(int id, int ds) {
  if (id == n + 1)
    return;
  else {
    if (vis[id] == 1)
      dfs1(id + 1, ds);
    else {
      co[id] -= ds;
      dfs1(id + 1, ds);
      if (co[id] < 0) {
        vis[id] = 1;
        dfs1(id + 1, dd[id]);
      }
    }
  }
}
void dfs(int id, int dec) {
  if ((id == n + 1) || (dec < 0))
    return;
  else if (vis[id] == 1)
    dfs(id + 1, dec);
  else {
    co[id] -= dec;
    dfs(id + 1, dec - 1);
    if (co[id] < 0) {
      vis[id] = 1;
      dfs1(id + 1, dd[id]);
    }
  }
}
int main() {
  int t, k, i, j, p;
  long long x, y, prev;
  cin >> x >> y;
  string ans;
  vector<long long> cnt;
  char c1 = 'A';
  char c2 = 'B';
  while ((x != 1) || (y != 1)) {
    if (x == y) break;
    if (x > y) {
      prev = x;
      x = x % y;
      long long ct = (prev - x) / y;
      if (x == 0) {
        x += y;
        ct--;
      }
      ans.push_back(c1);
      cnt.push_back(ct);
    } else {
      prev = y;
      y = y % x;
      long long ct = (prev - y) / x;
      if (y == 0) {
        y += x;
        ct--;
      }
      ans.push_back(c2);
      cnt.push_back(ct);
    }
  }
  if (x != 1)
    cout << "Impossible\n";
  else {
    for (i = 0; i <= ans.size() - 1; ++i) cout << cnt[i] << ans[i];
  }
}
