#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long LL;
int n , A , B , C , D , k;

inline bool check(int len)
{
	int a = A - len / (k + 1) * k - len % (k + 1) , b = B - len / (k + 1);
	return b <= (LL)a * k;
}

int main()
{
	scanf("%d" , &n);
	while(n--)
	{
		scanf("%d%d%d%d" , &A , &B , &C , &D);
		int l = 0 , r = A + B + 1 , mid , ans = r; k = max(ceil(1.0 * A / (B + 1)) , ceil(1.0 * B / (A + 1)));
		while(l <= r)
		{
			mid = (l + r) >> 1;
			if(check(mid)) l = mid + 1; else r = mid - 1 , ans = mid;
		}
		l = ans;
		int a = A - l / (k + 1) * k - l % (k + 1) , b = B - l / (k + 1);
		r = l + b - a * k + 1;
		for(int i = C ; i <= min(l , D) ; ++i) if(i % (k + 1)) putchar('A'); else putchar('B');
		for(int i = max(C , l + 1) ; i <= D ; ++i) if((i - r) % (k + 1)) putchar('B'); else putchar('A');
		putchar('\n');
	}
}