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

int q;
string s;

void solve(int a,int b,int c,int d,char AA,char BB)
{
	int n=a+b,k;
	k=n/(b+1);
	int l=0,r=a/k+1,mid;
	while (r-l>1)
		{
			mid=(l+r)>>1;
			((k*mid+(b-mid)/k<=a)?l:r)=mid;
		}
	int x=l,y=(b-x)/k;
	a-=k*x+y;
	for (int i=c; i<=d; i++)
		if (i<=x*(k+1))  s+=(i%(k+1)?AA:BB);
		else  if (n-i+1<=y*(k+1))  s+=((n-i+1)%(k+1)?BB:AA);
		else  s+=(i<=x*(k+1)+a?AA:BB);
}

void work()
{
	scanf("%d",&q);
	for (int a,b,c,d; q--; )
		{
			scanf("%d %d %d %d",&a,&b,&c,&d),s="";
			if (a>b)
				{
					solve(a,b,c,d,'A','B');					
				}else  if (a<b)
				{
					solve(b,a,(a+b+1)-d,(a+b+1)-c,'B','A');
					reverse(s.begin(),s.end());
				}else
				{
					for (int i=c; i<=d; i++)
						s+=(i&1?'A':'B');
				}
			cout<<s<<endl;
		}
}

int main()
{
	work();
	return 0;
}
