#include <bits/stdc++.h>
using namespace std;
int dx4[] = {-1, 0, 1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
void Duxar(int _this_line) {}
bool AreEqual(double a, double b) { return (fabs(a - b) < 1e-10); }
template <class T>
bool GetNr(T &_value) {
  T _sign = 1;
  char ch;
  _value = 0;
  while (!isdigit(ch = getchar())) {
    if (ch == -1) {
      return false;
    }
    ch == '-' ? _sign = -1 : _sign = 1;
  }
  do {
    _value = _value * 10 + (ch - '0');
  } while (isdigit(ch = getchar()));
  _value *= _sign;
  return true;
}
long long X, Y;
vector<pair<long long, char> > ans;
long long GetGcd(long long x, long long y) { return y ? GetGcd(y, x % y) : x; }
int main() {
  string fileInput = "sum";
  int i;
  GetNr(X);
  GetNr(Y);
  if (GetGcd(X, Y) != 1) {
    cout << "Impossible\n" << '\n';
    return 0;
  }
  while (X > 1 || Y > 1) {
    if (X == 1) {
      ans.push_back(make_pair(Y - 1, 'B'));
      break;
    } else if (Y == 1) {
      ans.push_back(make_pair(X - 1, 'A'));
      break;
    } else if (X > Y) {
      ans.push_back(make_pair(X / Y, 'A'));
      X %= Y;
    } else {
      ans.push_back(make_pair(Y / X, 'B'));
      Y %= X;
    }
  }
  for (auto p : ans) {
    cout << p.first << p.second;
  }
  putchar('\n');
  return 0;
}
