#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
//#include<assert.h>
#include<algorithm> 
#include<iostream>
//#include<bitset>
using namespace std;

int q,a,b,c,d,len;

int calc(int a,int b)
{
	if (!a || !b) return a^b;
	if (a<b) a^=b,b^=a,a^=b;
	return (a-1)/(b+1)+1;
}

bool check(int x)
{
	int cnta=x/(len+1)*len+x%(len+1),cntb=x/(len+1)-(x%(len+1)==0);
//	cout<<x<<' '<<cnta<<' '<<cntb<<endl;
	if (cnta>a) return 0;
	return calc(a-cnta,b-cntb)<=len;
}

void workleft(int left,int right)
{
	for (int i=left;i<=right;i++)
	{
		if (i%(len+1)==0) putchar('B');
		else putchar('A');
	}
}
void workright(int left,int right)
{
	for (int i=left;i<=right;i++)
	{
		if ((a+b-i+1)%(len+1)==0) putchar('A');
		else putchar('B');
	}
}

int main()
{
	scanf("%d",&q);
	while (q--)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		len=calc(a,b);
//		cout<<len<<endl;
		int L=0,R=a+b;
		while (L<R)
		{
			int mid=(L+R+1)>>1;
//			cout<<mid<<endl;
			if (check(mid)) L=mid;
			else R=mid-1;
		}
		int pos=L;
//		cout<<pos<<endl;
		if (d<=pos) workleft(c,d);
		else if (c>pos) workright(c,d);
		else workleft(c,pos),workright(pos+1,d);
		puts("");
	}
	return 0;
}