#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000005,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int T,n,m,l,r,K;
struct node{int x,y,t;}a[10];
int calc(int n,int m){return (max(n,m)-1)/(min(n,m)+1)+1;}
int calc(int n,int m,int fl){
	if (fl) return min(n,m) ? ((max(n,m)-1)/min(n,m)+1) : inf;
	if (!n) return inf;
	if (!m) return n;
	return max((n-1)/(m+1)+1,(m-1)/n+1);
}
int work(int n,int m,int fl){
	int l=0,r=min(n/K,m),mid;
	while (l<r){
		mid=(l+r+1)>>1;
		if (calc(n-mid*K,m-mid,fl)<=K) l=mid;
		else r=mid-1;
	}
	return l;
}
int main(){
	T=read();
	while (T--){
		n=read();m=read();l=read();r=read();
		K=calc(n,m);
		int t=work(n,m,0);
		a[1]=(node){K,1,t};
		n-=K*t;m-=t;
		t=work(m,n,a[1].t>0);
		a[3]=(node){1,K,t};
		n-=t;m-=K*t;
		a[2]=(node){n,m,1};
		int now=0;
		for (int i=1;i<=3;i++)
		if (a[i].x+a[i].y){
			if (now<l){
				int t=min((l-now-1)/(a[i].x+a[i].y),a[i].t);
				a[i].t-=t;now+=(a[i].x+a[i].y)*t;
			}
			while ((a[i].t)&&(now<r)){
				int t=max(l-now,1);now=max(now,l-1);
				for (int j=t;(now<r)&&(j<=a[i].x+a[i].y);j++,now++) putchar((j<=a[i].x) ? 'A' : 'B');
				a[i].t--;
			}
		}
		putchar('\n');
	}
	return 0;
}