#include <bits/stdc++.h>
using namespace std;
long double eps = 1 / (1e7);
long long int x, y;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
bool solve() {
  pair<long long int, long long int> A = make_pair(1, 0);
  pair<long long int, long long int> B = make_pair(0, 1);
  long long int num, den, apples = x, oranges = y;
  long long int n, m, cnt = 0;
  stringstream s;
  while (++cnt <= (int)2e6) {
    num = (y * A.second - A.first * x);
    den = (B.first * x - y * B.second);
    if (den)
      num /= den;
    else
      num = 0;
    n = num;
    A.second += n * B.second;
    A.first += n * B.first;
    if (A.first == y && A.second == x) {
      if (n > 1) s << (n - 1) << "B";
      string st = s.str();
      cout << st;
      return 1;
    } else if (n > 0)
      s << n << "B";
    num = (B.second * y - x * B.first);
    den = (x * A.first - y * A.second);
    if (den)
      num /= den;
    else
      num = 0;
    m = num;
    B.second += m * A.second;
    B.first += m * A.first;
    if (B.first == y && B.second == x) {
      if (m > 1) s << (m - 1) << "A";
      string st = s.str();
      cout << st;
      return 1;
    } else if (m > 0)
      s << m << "A";
    num = den = 0;
  }
  return 0;
}
int main() {
  cin >> y >> x;
  if (y == x) {
    cout << "Impossible";
    return 0;
  }
  if (!solve()) cout << "Impossible";
}
