#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {
  if (a == 0 or b == 0) return a + b;
  return gcd(b, a % b);
}
ll sum(ll a, ll b) {
  a += b;
  a %= mod;
  return a;
}
ll sub(ll a, ll b) {
  a += mod - b;
  a %= mod;
  return a;
}
inline ll mul(ll a, ll b) {
  if (a * b < mod) return a * b;
  return a * b % mod;
}
inline ll pew(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b /= 2;
  }
  return res;
}
int parent[600001];
int rnk[600001];
void make_set(int v) {
  parent[v] = v;
  rnk[v] = 0;
}
int find_set(int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (rnk[a] < rnk[b]) swap(a, b);
    parent[b] = a;
    if (rnk[a] == rnk[b]) ++rnk[a];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  ll x, y;
  cin >> x >> y;
  vector<pair<ll, ll>> ans;
  while (x > 1 or y > 1) {
    if (x > y) {
      if (x % y == 0 and y != 1) {
        cout << "Impossible" << endl;
        return 0;
      }
      ll d = (x - 1) / y;
      x -= y * d;
      ans.push_back({d, 1});
      continue;
    } else {
      if (y % x == 0 and x != 1) {
        cout << "Impossible" << endl;
        return 0;
      }
      ll d = (y - 1) / x;
      y -= x * d;
      ans.push_back({d, 2});
      continue;
    }
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first;
    if (ans[i].second == 1) {
      cout << "A";
    } else
      cout << "B";
  }
}
