#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int Q;
    cin>>Q;
    while(Q--) {
	int A=gi(),B=gi(),C=gi(),D=gi(),k=(max(A,B)-1)/(min(A,B)+1)+1;
	int l=1,r=A+B,a,b;
	while(l<=r) {
	    int mid=(l+r)>>1;
	    a=A-mid/(k+1)*k-mid%(k+1),b=B-mid/(k+1);
	    if(mid%(k+1)) ++a;
	    if(1LL*a*k>=b) l=mid+1;
	    else r=mid-1;
	}
	a=A-r/(k+1)*k-r%(k+1),b=B-r/(k+1);
	if(r%(k+1)||!r) ++a;
	l=r+b-1LL*a*k;
	for(int i=C;i<=min(r,D);i++) putchar(i%(k+1)?'A':'B');
	for(int i=max(C,r+1);i<=D;i++) putchar((i-l)%(k+1)?'B':'A');
	puts("");
    }
    return 0;
}