#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
#define FOREACH(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it ++)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i ++)
#define DOW(i, b, a) for(int i = (b), _a = (a); i >= _a; i --)
#define REP(i, n) FOR(i, 0, (n) - 1)
#define DEP(i, n) DOW(i, (n) - 1, 0)
#define all(a) (a).begin(), (a).end()
#define pb(a, b) (a).push_back((b))
#define pf(a, b) (a).push_front((b))
#define ave(a, b) (a+b)/2
#define RI(a) scanf("%d", &a)
#define RII(a) scanf("%I64d", &a)
typedef vector <int> VI;
typedef vector <string> VS;
typedef pair <int, int> PII;
typedef vector <PII> VII;
typedef long long int64;
template <class T> inline int size(const T&c) { return c.size(); }
template <class T> inline int lenght(const T&c) { return c.length(); }
int n, r;
bool istrace;
string trace;
int mistake(int t, int b, char next, int lv) {
if (t == b)
if (t == 1 && lv+1 == n) {
trace = "T";
return next == 'T';
}
else return 1e9;
if (t > b) {
int ret = mistake(t-b, b, 'T', lv+1)+(next=='T');
if (istrace) trace += "T";
return ret;
}
else {
int ret = mistake(t, b-t, 'B', lv+1)+(next=='B');
if (istrace) trace += "B";
return ret;
}
}
int main() {
RI(n); RI(r);
if (r == 1) {
if (n == 1) cout << 0 << endl << "T";
else cout << "IMPOSSIBLE";
return 0;
}
istrace = false;
int ret = 1e9, t = -1;
FOR(i, 1, r-1) {
int tmp = 1e9;
if (i > r-i) tmp = mistake(i, r-i, 'B', 1);
if (i < r-i) tmp = mistake(i, r-i, 'T', 1);
if (ret > tmp) {
ret = tmp;
t = i;
}
}
if (t == -1) cout << "IMPOSSIBLE";
else {
istrace = true;
trace = "";
if (t > r-t) { mistake(t, r-t, 'B', 1); trace += "B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