#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define pll pair<int64,int64>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}

int64 A,B,C,D,ML;
vector<pll > vA,vB;
bool check(int64 a,int64 b,int64 k) {
    int64 t = (a - 1) / k;
    if(b < t) return false;
    t += 2;
    if(b > t * k) return false;
    return true;
}
void Process(int64 l,int64 r) {
    int p = 0,q = 0;
    int64 len = 1;
    int64 c = 0;
    while(len <= ML) {
	int64 t = min(vA[p].se,vB[q].se);
	vA[p].se -= t;vB[q].se -= t;
	if(len >= l) {
	    int64 k = t;
	    while(k--) {
		for(int64 i = 1 ; i <= vA[p].fi ; ++i) {
		    putchar('A');++c;
		    if(c == r - l + 1) return;
		}
		for(int64 i = 1 ; i <= vB[q].fi ; ++i) {
		    putchar('B');++c;
		    if(c == r - l + 1) return;
		}
	    }
	}
	else if(len + t * (vA[p].fi + vB[q].fi) - 1 >= l){
	    int64 k = (l - len) % (vA[p].fi + vB[q].fi) + 1;
	    int64 h = t - (l - len) / (vA[p].fi + vB[q].fi);
	    --h;
	    if(k <= vA[p].fi) {
		for(int64 i = k ; i <= vA[p].fi ; ++i) {
		    putchar('A');++c;
		    if(c == r - l + 1) return;
		}
		for(int64 i = 1 ; i <= vB[q].fi ; ++i) {
		    putchar('B');++c;
		    if(c == r - l + 1) return;
		}
	    }
	    else {
		k -= vA[p].fi;
		for(int64 i = k ; i <= vB[q].fi ; ++i) {
		    putchar('B');++c;
		    if(c == r - l + 1) return;
		}
	    }
	    while(h--) {
		for(int64 i = 1 ; i <= vA[p].fi ; ++i) {
		    putchar('A');++c;
		    if(c == r - l + 1) return;
		}
		for(int64 i = 1 ; i <= vB[q].fi ; ++i) {
		    putchar('B');++c;
		    if(c == r - l + 1) return;
		}
	    }
	}
	len += t * (vA[p].fi + vB[q].fi);
	if(vA[p].se == 0) ++p;
	if(vB[q].se == 0) ++q;
    }
}
void Solve() {
    read(A);read(B);read(C);read(D);
    int64 L = 1,R = max(A,B);
    ML = (A + B);
    while(L < R) {
    	int64 mid = (L + R) >> 1;
    	if(check(A,B,mid) || check(B,A,mid)) R = mid;
    	else L = mid + 1;
    }
    vA.clear();vB.clear();
    if(A == ((B - 1) / L)) {
    	int64 t = B / L;
    	int64 rem = B - L * t;
    	vA.pb(mp(0,1));
    	vA.pb(mp(1,A));
    	if(rem) vB.pb(mp(rem,1));
    	vB.pb(mp(L,t));
    }
    else if(B == (A - 1) / L){
        int64 t = A / L;
        int64 rem = A - t * L;
        vA.pb(mp(L,t));
        if(rem) vA.pb(mp(rem,1));
        vB.pb(mp(1,B));vB.pb(mp(0,1));
    }
    else {
        int64 l = max((A - 1) / L + 1,(B - 1) / L + 1),r = min(A,B);
        while(l < r) {
            int64 m = (l + r + 1) >> 1;
            int64 ta = (A - m) / (L - 1);
            int64 tb = (B - m) / (L - 1);
            ta = ta * 2 + 1;
            tb = 2 * m - (tb * 2);
            if(ta + 1 < tb) r = m - 1;
            else l = m;
        }
        if(A > l) {
            int64 ka = (A - l - 1) / (L - 1);
            int64 rem = A - l - ka * (L - 1);
            vA.pb(mp(L,ka));vA.pb(mp(1 + rem,1));vA.pb(mp(1,l - ka - 1));
        }
        else vA.pb(mp(1,l));
        if(B > l) {
            int64 kb = (B - l - 1) / (L - 1);
            int64 rem = B - l - kb * (L - 1);
            vB.pb(mp(1,l - kb - 1));vB.pb(mp(1 + rem,1));vB.pb(mp(L,kb));
        }
        else vB.pb(mp(1,l));
    }
    Process(C,D);
    enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    int Q;
    read(Q);
    while(Q--) {
    	Solve();
    }
}


Measured memory_bytes: 384