/*{{{*/
//#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &_x) { cin >> _x; }
void _R(int &_x) { scanf("%d", &_x); }
void _R(int64_t &_x) { scanf("%" SCNd64, &_x); }
void _R(double &_x) { scanf("%lf", &_x); }
void _R(char &_x) { scanf(" %c", &_x); }
void _R(char *_x) { scanf("%s", _x); }
template<class T, class U> void _R(pair<T, U> &_x) {_R(_x.F); _R(_x.S);}
void R() {}
template<class T, class... U> void R(T &_head, U &... _tail) { _R(_head); R(_tail...); }

template<class T> void _W(const T &_x) { cout << _x; }
void _W(const int &_x) { printf("%d", _x); }
void _W(const int64_t &_x) { printf("%" PRId64, _x); }
void _W(const double &_x) { printf("%.16f", _x); }
void _W(const char &_x) { putchar(_x); }
void _W(const char *_x) { printf("%s", _x); }
template<class T, class U> void _W(const pair<T, U> &_x) {_W(_x.F); putchar(' '); _W(_x.S);}
template<class T> void _W(const vector<T> &_x) { for (auto i = _x.begin(); i != _x.end(); _W(*i++)) if (i != _x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &_head, const U &... _tail) { _W(_head); putchar(sizeof...(_tail) ? ' ' : '\n'); W(_tail...); }

template<class T, class... U> void DB(const T &_head, const U &... _tail) {
#ifdef HOME
    W('#', _head, _tail...);
#endif
}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)

#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef int64_t ll;

inline int LG (const unsigned int &_x) { return 32-__builtin_clz(_x); } // floor: LG(x), ceil: LG(x-1)+1
/*}}}*/

int q;
int a, b, c, d;

int main(){
    R(q);
    FOR(_, q){
        R(a, b, c, d);
        int le = 1, ri = max(a, b);
        while(le < ri){
            int mi = (le+ri)/2;
            //int aa = (a-1)/mi+1, bb = (b-1)/mi+1;
            //int val = abs(aa-bb);
            ll bl = (a-1)/mi+1-1, br = (a+1LL)*mi;
            int val = bl<=b && b<=br;
            if(val == 0) le = mi+1;
            if(val == 1) ri = mi;
        }
        int k = le;
        //int aa = (a-1)/k+1, bb = (b-1)/k+1;
        //int aq = a/k, ar = a%k, bq = b/k, br = b%k;
        //ar = ar ? ar : k, br = br ? br : k;
        string ans = "";
        // a*k, b, ..., a*a_, b*b_, a, b*k, ..., a, b*k
        // 1 <= a_, b_ <= k
        // k*x + a_ +   y = a
        //   x + b_ + k*y = b
        // (k-1)(x-y) = (a-a_)-(b-b_)
        // (k+1)(x+y) = (a-a_)+(b-b_)
        // a_ + b_ = a + b (mod k+1)
        // a_ - b_ = a - b (mod k-1)
        if(k==1){
            if(a>=b)
                for(int p=c; p<=d; ++p) ans += (char)('B'-(p&1));
            else
                for(int p=c; p<=d; ++p) ans += (char)('A'+(p&1));
            W(ans);
            continue;
        }

        if((a-1)/k+1==b+1){

        }

        vi f1, f2, x, y;

        int t = (a+b)%(k+1);
        for(int i=0; t+i<=k+k; i+=k+1) f1.EB(t+i);
        for(int i=-k-1; 0<=t+i; i-=k+1) f1.EB(t+i);

        t = (a-b)%(k-1);
        for(int i=0; t+i<=k; i+=k-1) f2.EB(t+i);
        for(int i=-k+1; -k<=t+i; i-=k-1) f2.EB(t+i);

        for(int v1: f1) for(int v2: f2){
            if((v1+v2)&1) continue;
            int aa = (v1+v2)/2, bb = (v1-v2)/2;
            if(aa<0 || k<aa || bb<0 || k<bb) continue;
            aa = a-aa, bb = b-bb;
            int xx = (aa+bb)/(k+1), yy = (aa-bb)/(k-1);
            if((xx+yy)&1) continue;
            x.EB((xx+yy)/2), y.EB((xx-yy)/2);
            if(x.back()<0 || y.back()<0){ x.pop_back(), y.pop_back(); continue; }
            if(aa==a && x.back()!=0){ x.pop_back(), y.pop_back(); continue; }
            if(bb==b && y.back()!=0){ x.pop_back(), y.pop_back(); continue; }
        }
        assert(!x.empty()), assert(!y.empty());
        //assert(x.size()==1);

        vi id;
        FOR(i, SZ(x)) id.EB(i);
        sort(ALL(id), [x, y, k](int i, int j){
             if(x[i] != x[j]) return x[i] > x[j];
             int aai = a-y[i]-k*x[i], aaj = a-y[j]-k*x[j];
             return aai > aaj;
             if(aai != aaj) return aai > aaj;
             //int bbi = b-k*y[i]-x[i], bbj = b-k*y[j]-x[j];
             //if(bbi != bbj) return bbi < bbj;

             });

        int xx = x[0], yy = y[0], aa = a-y[0]-k*x[0], bb = b-k*y[0]-x[0];
        DB(xx, yy, aa, bb);
        int p = c;
        int sh = (p-1)%(k+1);
        for(; p <= (k+1)*xx && p <= d; ++p, sh=++sh==k+1?0:sh){
            if(sh<k) ans += "A";
            else ans += "B";
        }
        for(; p <= (k+1)*xx+aa && p <= d; ++p) ans += "A";
        for(; p <= (k+1)*xx+aa+bb && p <= d; ++p) ans += "B";

        sh = (p-(k+1)*xx-aa-bb-1)%(k+1);
        for(; p <= a+b && p <= d; ++p, sh=++sh==k+1?0:sh){
            if(sh==0) ans += "A";
            else ans += "B";
        }

        /*
        if(aa > bb){
            // a*k, b*br, a*k, b*k, ... , a*k, b*k, a*ar
            int p = c;
            while(p <= k && p <= d) ans += "A", ++p;
            while(p <= k+br && p <= d) ans += "B", ++p;

            int ab = (p-k-br-1)%(k+k);
            while(p <= a+b-ar && p <= d){
                ans += (char)('A'+ab/k);
                ++ab, ++p;
                if(ab == k+k) ab = 0;
            }
            while(p <= a+b && p <= d) ans += "B", ++p;
        }
        else if(aa == bb){
            // a*k, b*br, a*k, b*k, ... , a*ar, b*k
            int p = c;
            int a0 = aa==1 ? ar : k, b1 = bb==1 ? br : k;
            while(p <= a0 && p <= d) ans += "A", ++p;
            while(p <= k+br && p <= d) ans += "B", ++p;

            int ab = (p-a0-br-1)%(k+k);
            while(p <= a+b-ar-b1 && p <= d){
                ans += (char)('A'+ab/k);
                ++ab, ++p;
                if(ab == k+k) ab = 0;
            }
            while(p <= a+b-b1 && p <= d) ans += "A", ++p;
            while(p <= a+b && p <= d) ans += "B", ++p;
        }
        else{
            // b*br, a*k, b*k, ... , a*ar, b*k
            int p = c;
            int a0 = aa==1 ? ar : k, b1 = bb==1 ? br : k;
            while(p <= br && p <= d) ans += "B", ++p;
            //while(p <= k+br && p <= d) ans += "A", ++p;

            int ab = (p-br-1)%(k+k);
            while(p <= a+b-ar-k && p <= d){
                ans += (char)('A'+ab/k);
                ++ab, ++p;
                if(ab == k+k) ab = 0;
            }
            while(p <= a+b-k && p <= d) ans += "A", ++p;
            while(p <= a+b && p <= d) ans += "B", ++p;
        }
        // */
        W(ans);
    }

    return 0;
}
/*
5
2 3 1 5
6 4 1 10
2 3 4 4
6 4 3 7
8 10 5 8

babab
aabaabaabb
aabaababbabbabbabb
*/


Measured memory_bytes: 384