#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int ask(int a,int b,int p)
{
	if(a<b)return !ask(b,a,a+b-p+1);
	int k=(a-1)/(b+1)+1;
	int c=a/k;
	b-=c,a%=k;
	if((a&&b<=k)||(a==0&&b<k))
	{
		if(p<=(k+1)*c)return p%(k+1)==0;
		p-=(k+1)*c;
		return p>a;
	}
	int x;
	if(k*(a+1)-1>=b)x=0;
	else x=(int)((b-k*a-k)/(1ll*k*k-1)+1);
	c-=x;
	a+=x*k,b+=x;
	int cc=b/k;
	a-=cc,b%=k;
	if(p<=(k+1)*c)return p%(k+1)==0;
	p-=(k+1)*c;
	if(p<=a+b)return p>a;
	p-=a+b;
	return p%(k+1)!=1;
}
int q;
int main()
{
	scanf("%d",&q);
	while(q--)
	{
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		for(int i=c;i<=d;i++)putchar('A'+ask(a,b,i));
		putchar('\n');
	}
	return 0;
}