#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline bool ok(ll ra,ll rb,ll k,ll tag)
{ll rm=ra+rb,nda=rm/(k+1),ndb=rm-nda;
if (tag==0&&nda==ra) return 0;
return (nda<=ra);
}
inline char getf(ll pos,ll k)
{return (pos%(k+1)==0?'B':'A');}
inline char getb(ll pos,ll k)
{return (pos%(k+1)==0?'A':'B');}
int main (){
	ll q,a,b,c,d;
	scanf ("%lld",&q);
	while (q--)
	{scanf ("%lld%lld%lld%lld",&a,&b,&c,&d);
	ll k=(max(a,b)-1)/(min(a,b)+1)+1;
	ll l=0,r=a+b;
	while (l<=r)
	{ll mid=(l+r)>>1ll;
	ll rod=mid/(k+1),rm=mid-rod*(k+1);
	ll ra=a-(rod*k+rm),rb=b-rod;
	if (ok(ra,rb,k,rm)) {l=mid+1;}
	else {r=mid-1;}
	}
	for (ll i=c;i<=min(r,d);i++) putchar(getf(i,k));
	for (ll i=max(c,r+1);i<=d;i++) putchar(getb(a+b-i+1,k));
	puts("");
	}
	return 0;
}
	