#include<bits/stdc++.h>
using namespace std;

#define int long long
int T , A , B , C , D , now;

void add(int numa , int numb , int cnt = 1){
	if((!numa && !numb) || now > D) return;
	int len = numa + numb , tms = min(cnt , max(0ll , (C - now - 1) / len));
	cnt -= tms; now += len * tms;
	while(now <= D && cnt--){
		int len = numa , lft = max(C - now - 1 , 0ll);
		now += min(len , lft); len -= min(len , lft);
		while(len-- && ++now <= D) putchar('A');
		len = numb; lft = max(C - now - 1 , 0ll);
		now += min(len , lft); len -= min(len , lft);
		while(len-- && ++now <= D) putchar('B');
	}
}

signed main(){
	for(cin >> T ; T ; --T){
		cin >> A >> B >> C >> D; now = 0;
		int t = (A + B) / min(A + 1 , B + 1) , l = 0 , r = A / t;
		while(l < r){int mid = (l + r + 1) >> 1; t * (A - t * mid) >= B - mid ? l = mid : r = mid - 1;}
		add(t , 1 , l); A -= l * t; B -= l;
		if(!B){add(A , 0); putchar('\n'); continue;}
		int numa = ((A + 1) * t - B) / t; A -= numa; add(numa , B - t * A); add(1 , t , A);
		putchar('\n');
	}
	return 0;
}