#include <bits/stdc++.h>
using namespace std;
vector<pair<char, long long int> > res;
int main() {
  ios_base::sync_with_stdio(0);
  long long int x, y;
  cin >> x >> y;
  while (x != y) {
    if (x > y) {
      long long int div = x / y;
      x -= div * y;
      if (x == 0) {
        x = y;
        div--;
      }
      res.push_back(make_pair('A', div));
    } else {
      long long int div = y / x;
      y -= div * x;
      if (y == 0) {
        y = x;
        div--;
      }
      res.push_back(make_pair('B', div));
    }
  }
  if (x != 1) {
    cout << "Impossible" << endl;
  } else {
    for (int i = (0); i < (res.size()); ++i) {
      char let = res[i].first;
      long long int ile = res[i].second;
      cout << ile << let;
    }
    cout << endl;
  }
}
