#include <bits/stdc++.h>
using namespace std;
int nxt() {
  int a;
  scanf("%d", &a);
  return a;
}
vector<pair<int64_t, int64_t> > ans;
bool g(long long first, long long second) {
  while (true) {
    if (first == 0 || second == 0) {
      if (first == 0 && second != 1) {
        cout << "Impossible\n";
        return false;
      }
      if (second == 0 && first != 1) {
        cout << "Impossible\n";
        return false;
      }
      return true;
    }
    if (first > second) {
      ans.push_back(std::make_pair(first / second, 'A'));
      first %= second;
    } else {
      ans.push_back(std::make_pair(second / first, 'B'));
      second %= first;
    }
  }
}
void solve() {
  long long first, second;
  cin >> first >> second;
  if (g(first, second)) {
    ans.back().first--;
    for (pair<int64_t, int64_t> p : ans) {
      if (p.first == 0) continue;
      cout << p.first << char(p.second);
    }
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
