#include <bits/stdc++.h>
const long long inf = 9223372036854775807ll;
const int iinf = 2147483647;
const int limit = 1048576;
using namespace std;
bool sync_with_stdio(bool sync = false);
string res;
void move_bob(pair<long long, long long> u, pair<long long, long long> w,
              pair<long long, long long> v);
void move_alice(pair<long long, long long> u, pair<long long, long long> w,
                pair<long long, long long> v) {
  if (w.first * v.second - w.second * v.first == 0) {
    res = "Impossible";
    return;
  }
  long long k = (v.first * u.second - u.first * v.second) /
                (w.first * v.second - w.second * v.first);
  if (u.first + k * w.first > v.first || u.second + k * w.second > v.second) {
    res = "Impossible";
    return;
  }
  if (u.first + k * w.first == v.first && u.second + k * w.second == v.second) {
    ostringstream oss;
    oss << k - 1;
    res += oss.str();
    res.push_back('A');
    return;
  }
  ostringstream oss;
  oss << k;
  res += oss.str();
  res.push_back('A');
  move_bob(make_pair(u.first + k * w.first, u.second + k * w.second), w, v);
}
void move_bob(pair<long long, long long> u, pair<long long, long long> w,
              pair<long long, long long> v) {
  if (u.second * v.first - u.first * v.second == 0) {
    res = "Impossible";
    return;
  }
  long long k = (w.first * v.second - v.first * w.second) /
                (u.second * v.first - u.first * v.second);
  if (w.first + k * u.first > v.first || w.second + k * u.second > v.second) {
    res = "Impossible";
    return;
  }
  if (w.first + k * u.first == v.first && w.second + k * u.second == v.second) {
    ostringstream oss;
    oss << k - 1;
    res += oss.str();
    res.push_back('B');
    return;
  }
  ostringstream oss;
  oss << k;
  res += oss.str();
  res.push_back('B');
  move_alice(u, {w.first + k * u.first, w.second + k * u.second}, v);
}
int main() {
  long long v1, v2;
  cin >> v1 >> v2;
  if (v1 >= v2)
    move_alice({0ll, 1ll}, {1ll, 0ll}, {v1, v2});
  else
    move_bob({0ll, 1ll}, {1ll, 0ll}, {v1, v2});
  cout << res;
  return 0;
}
