/*
Author: CNYALI_LK
LANG: C++
PROG: d.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<ll,ll> pii;
template<class T>ll chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>ll chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
ll read(){
	ll s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WritellBuffer[1024];
template<class T>void write(T a,char end){
	ll cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WritellBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WritellBuffer[cnt]);--cnt;}
	putchar(end);
}
char s[102424];
ll len,l,r;
void w(ll l,ll r){
	for(ll i=l;i<=r;++i)putchar(s[i-l+1]);
	putchar('\n');
}
void ta(ll tim){
	if(tim<0)return;
//	printf("(%lld)Write %lld a\n",len,tim);
	if(len>=r||len+tim<l)len+=tim;
	else{

		if(len<l){
			tim-=l-len-1;
			len=l-1;
		}
		while(tim){
			--tim;
			s[(++len)-l+1]='A';
			if(len>=r){
				len+=tim;return;
			}
		}
	}
}
void tb(ll tim){
	if(tim<0)return;
//	printf("(%lld)Write %lld a\n",len,tim);
//	printf("Write %lld b\n",tim);
	if(len>=r||len+tim<l)len+=tim;
	else{
		if(len<l){
			tim-=l-len-1;
			len=l-1;
		}
		while(tim){
			--tim;
			s[(++len)-l+1]='B';
//			printf("On %lld\n",len-l+1);
			if(len>=r){
				len+=tim;return;
			}
		}
	}
}
void t(ll a,ll b,ll ti){
	len=0;
	if(ti==1){
		for(ll i=l;i<=r;++i)s[++len]='B'-((i&1)^(a<b));
		return;
	}
	ll tim=(a*ti-b+1)/(ti*ti-1),allsiz=tim*(ti+1);
	if(r<=allsiz){
		ll k=(l-1)/(ti+1)*(ti+1);
		len+=k;
		while(len<=r){
			ta(ti);
			tb(1);
		}
		return;
	}
	else if(allsiz<l)len+=allsiz;
	else{
		ll k=(l-1)/(ti+1);
		len+=k*(ti+1);
		while(++k<=tim){
			ta(ti);
			tb(1);
		}
	}
	a-=tim*ti;
	b-=tim;
//	printf("%lld %lld\n",tim,len);
	ll k=a-(b-1)/ti;
	ta(k);
	a-=k;
	ll aw=((b-1)%ti+1);
	tb(aw);
	b-=aw;
	if(a&&aw){ta(1);--a;}
//	printf("%lld+%lld %lld\n",len,a,b);
//	printf("adyyc(%lld %lld)\n",a,b);
	if(r<=len+a*(ti+1)){
		if(l<=len){
			while(a&&len<=r){
				tb(ti);
				ta(1);
				b-=ti;
				--a;
			}
		}
		else{
			tim=max((l-len-1)/(ti+1),0LL)*(ti+1);
			len+=tim;
			while(len<=r){
				tb(ti);
				ta(1);
			}
		}	
		return;
	}
	else if(len+a*(ti+1)<l){
		len+=a*(ti+1);
		b-=a*ti;
		a-=ti;
	}
	else{
		tim=max((l-len-1)/(ti+1),0LL);
		ll s=tim*(ti+1);
//		printf("hhsb(%lld %lld)\n",tim,s);
		len+=s;
		while(tim<a){
			tb(ti);	
			ta(1);
			++tim;
		}	
		b-=a*ti;
		a-=ti;
	}
	tb(b);
	ta(a);
//	printf("%lld\n",len);
}
int main(){
#ifdef cnyali_lk
	freopen("d.in","r",stdin);
	freopen("d.out","w",stdout);
#endif
	ll q,a,b;
	q=read();
	while(q){
		--q;
		a=read();b=read();
		l=read();r=read();
		if(a>b){
			ll s=(ll)ceil(a*1./(b+1));
			t(a,b,s);
		}
		else{
			ll s=(ll)ceil(b*1./(a+1));
			t(a,b,s);
		}
		w(l,r);
//		debug("orz guo\n");
	}
	return 0;
}



Measured memory_bytes: 384