#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int ty,a,b,l,r,k;

int Div(int x,int y) {return x/y+((x%y)>0);}

int find(int a,int b) {
	int l=0,r=a+b+1,p=0;
	while (l<=r) {
		int mid=l+r>>1;
		int A=a-mid/(k+1)*k-mid%(k+1),B=b-mid/(k+1);
		if (B/k<=A) p=mid,l=mid+1;
		else r=mid-1;
	}
	return p;
}

int main() {
	for(scanf("%d",&ty);ty;ty--) {
		scanf("%d%d%d%d",&a,&b,&l,&r);
		k=Div(max(a,b),min(a,b)+1);
		int p=find(a,b);
		int A=a-p/(k+1)*k-p%(k+1),B=b-p/(k+1),d=p+B-A*k+1;
		for(int i=l;i<=min(p,r);i++) putchar(i%(k+1)?'A':'B');
		for(int i=max(l,p+1);i<=r;i++) putchar((i-d)%(k+1)?'B':'A');
		puts("");
	}
	return 0;
}