#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
int T,a,b,c,d,x,len;
int L,R,mid,A,B,border;
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
void work()
{
	a=read();b=read();len=a+b;
	c=read();d=read();
	if(a==b)
	{
		for(int i=c;i<=d;i++)
			if(i&1)putchar('A');
			else putchar('B');
		putchar('\n');return;
	}
	x=(max(a,b)-1)/(min(a,b)+1)+1;
	L=0;R=a;border=0;
	while(L<=R)
	{
		mid=(L+R)>>1;
		A=a-mid;B=b-mid/x;
		if(1ll*(A+1)*x-1>=B)border=mid,L=mid+1;
		else R=mid-1;
	}
	border+=border/x;
//	printf("bor %d\n",border);
	for(int i=c;i<=min(border,d);i++)
		if(i%(x+1)==0)putchar('B');
		else putchar('A');
	for(int i=max(c-1,border)+1;i<=d;i++)
		if((len-i+1)%(x+1)==0)putchar('A');
		else putchar('B');
	putchar('\n');
}
int main()
{
	T=read();
	while(T--)work();
	return 0;
}