#include<bits/stdc++.h>
 
using namespace std;
 
inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}
 
int main(){
	int t=read();
	while(t--){
		int a=read(),b=read(),c=read(),d=read();
		int n=a+b;
		int k=(max(a,b)-1)/(min(a,b)+1)+1;
		int l=0,r=n+1,x,y;
		while(l<r){
			int mid=l+r>>1;
			x=a-mid/(k+1)*k-mid%(k+1);
			y=b-mid/(k+1);
			if(y<=1ll*x*k) l=mid+1;
			else r=mid;
		}
		x=a-l/(k+1)*k-l%(k+1);y=b-l/(k+1);r=l+y-x*k+1;
		for(int i=c;i<=min(d,l);i++) {
			if(i%(k+1)) cout<<'A';
			else cout<<'B';
		} 
		for(int i=max(c,l+1);i<=d;i++){
			if((i-r)%(k+1)) cout<<'B';
			else cout<<'A';
		}
		cout<<endl;
	}  
 
 
	return 0;
}