#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:134217728")
const int MOD = 1000000007;
const int INF = 1000000001;
const int MAXN = 17;
const double EPS = 1e-6;
const int HASH_POW = 31;
const double PI = acos(-1.0);
using namespace std;
void my_return(int code) { exit(code); }
vector<pair<long long, char> > ans;
long long gcd(long long a, long long b) {
  while (a && b) {
    if (a > b) {
      if (b > 1)
        ans.push_back(make_pair(a / b, 'A'));
      else
        ans.push_back(make_pair(a / b - 1, 'A'));
      a %= b;
    } else {
      if (a > 1)
        ans.push_back(make_pair(b / a, 'B'));
      else
        ans.push_back(make_pair(b / a - 1, 'B'));
      b %= a;
    }
  }
  return a + b;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  mt19937 mt_rand(time(NULL));
  long long x, y;
  scanf("%I64d %I64d", &x, &y);
  long long g = gcd(x, y);
  if (g > 1)
    printf("Impossible\n");
  else {
    int k = 0;
    for (int i = 1; i < ans.size(); ++i) {
      if (ans[i].second == ans[k].second)
        ans[k].first += ans[i].first;
      else
        ans[++k] = ans[i];
    }
    for (int i = 0; i < ans.size(); ++i)
      printf("%I64d%c", ans[i].first, ans[i].second);
  }
  my_return(0);
}
