#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll a,b,c,d,len,l,r,mid,he,ta,mia,mib;
string s;

ll up(ll x,ll y){
	return (x+y-1)/y;
}
bool ck(){
	if (!mid) return 1;
	ll la=a-mid*len, lb=b-mid;
	if (!la) return !lb;
	if (lb<0) return 0;
	if (max(up(la,lb+1),up(lb,la))>len) return 0;
	return 1;
}

char cal(ll p){
	if (p<=(len+1)*he) return p%(len+1)? 'A': 'B';
	if (a+b-p+1<=(len+1)*ta) return (a+b-p+1)%(len+1)? 'B': 'A';
	return p<=(len+1)*he+mia? 'A': 'B';
}

void realmain(){
	s="";
	len=max(up(a,b+1),up(b,a+1));
	l=0; r=a/len;
	for (;l<=r;ck()? l=(he=mid)+1: r=mid-1) mid=l+r>>1;
	ll la=a-he*len, lb=b-he;
	ta=lb/len; mib=lb%len; mia=la-ta;
	for (ll i=c;i<=d;++i) s+=cal(i);
	cout<<s<<endl;
}

int main(){
	int T;
	for (cin>>T;T--;){
		cin>>a>>b>>c>>d;
		realmain();
	}
}