#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int calc(int n,int m){
	return max((n+m)/(m+1),(n+m)/(n+1));
}
int k,n,m,T,l,r,p,q,N,M,h;
int check(int x){
	if (x>n/k||x>m)return 0;
	int n1=n-x*k,m1=m-x;
	return (ll)k*(n1+1)>m1;
}
int check2(int x){
	return (ll)k*(n-x+1)>=m;
}
void write1(int l,int r){
	for (int i=l;i<=r;i++){
		putchar('A'+(i%(k+1)==0));
	}
}
void write(int l,int r){
	int sum=h*(k+1);
	if (l<=sum)
		write1(l,min(r,sum));
	if (r<=sum)return;
	l=max(l,sum+1);
	for (int i=l-sum;i<=p&&l<=r;i++,l++)putchar('A');
	sum+=p;
	for (int i=l-sum;i<=q&&l<=r;i++,l++)putchar('B');
	sum+=q;
	for (int i=l-sum-1;l<=r;i++,l++)
		putchar('A'+(i%(k+1)!=0));
}
int main(){
	for (cin>>T;T--;){
		scanf("%d%d%d%d",&n,&m,&l,&r);
		k=calc(n,m);N=n,M=m;
		h=p=q=0;
		for (int u=1<<30;u;u>>=1)
			if (check(h+u))h+=u;
		n-=h*k,m-=h;
		for (int u=1<<30;u;u>>=1)
			if (check2(p+u))p+=u;
		q=m-k*(n-p);
		write(l,r);
		putchar('\n');
	}
}