#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

int Q,A,B,L,R,i,j,k;

int main(){
	scanf("%d",&Q);
	while (Q--){
		scanf("%d%d%d%d",&A,&B,&L,&R);
		if (abs(A-B)<=1) {
			if (B>A) for(i=L;i<=R;i++) putchar('A'+(i&1));
			else for(i=L;i<=R;i++) putchar('A'+(i&1^1));
		} else {
			ll s;
			if (A>B) s=(A+B)/(B+1);
			else s=(A+B)/(A+1);
			ll c1=(s*A-B+1+(s*s-1-1))/(s*s-1)-1;
			ll c2=(s*B-A+1+(s*s-1-1))/(s*s-1)-1;
			ll res1=A-c1*s-c2,res2=B-c1-c2*s;
			for(i=L;i<=R;i++) 
				if (i<=c1*(s+1)) putchar('A'+(i%(s+1)==0)); else 
				if (A+B-i+1<=c2*(s+1)) putchar('B'-((A+B-i+1)%(s+1)==0)); else {
					if (i-c1*(s+1)<=res1) putchar('A');
					else putchar('B');
				}
		}
		putchar('\n');
	}
}