#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

struct group {
	cat n1, n2, rep;
	bool c1;
};

void build(string & S, vector<group> G, cat l, cat r) {
	for(auto g : G) if(g.n1+g.n2) {
		if(g.rep == 0) continue;
		cat n_init = min(g.rep, l / (g.n1+g.n2));
		l -= n_init * (g.n1+g.n2);
		r -= n_init * (g.n1+g.n2);
		g.rep -= n_init;
		while(r && g.rep) {
			cat n1 = g.n1, n2 = g.n2;
			char c1 = 'A', c2 = 'B';
			if(g.c1) swap(c1, c2);
			g.rep--;
			cat d = min(n1, l);
			n1 -= d, l -= d, r -= d;
			if(l) {
				d = min(n2, l);
				n2 -= d, l -= d, r -= d;
			}
			while(r && n1) {
				S += c1;
				n1--, r--;
			}
			while(r && n2) {
				S += c2;
				n2--, r--;
			}
		}
		if(!r) break;
	}
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int Q;
	cin >> Q;
	for(int q = 0; q < Q; q++) {
		cat a, b, l, r;
		cin >> a >> b >> l >> r;
		l--;
		string ans;
		cat L = 1;
		if(a > b) L = (a+b)/(b+1);
		if(b > a) {
			L = (a+b)/(a+1);
			cat fb = max(0LL, b-L*a);
			cat x = min(fb, l);
			l -= x, r -= x, fb -= x, b -= x;
			while(fb && r) {
				ans += 'B';
				fb--, b--, r--;
			}
		}
		if(!r) {
			cout << ans << "\n";
			continue;
		}
		cat min_L1 = 0, max_L1 = OVER9000;
		while(max_L1-1 > min_L1) {
			cat n_L1 = (min_L1 + max_L1) / 2;
			cat a_sub = a - n_L1 * L, b_sub = b - n_L1;
			bool ok = true;
			if(a_sub < 0 || b_sub < 0) ok = false;
			else if((b_sub+1) * L < a_sub) ok = false;
			else if(a_sub * L < b_sub) ok = false;
			if(ok) min_L1 = n_L1;
			else max_L1 = n_L1;
		}
		a -= min_L1 * L, b -= min_L1;
		if(a < L || b > (a+1-L)*L) { // b <= (a+1)L
			cat k_a = a+1-(b+L-1)/L;
			a -= k_a;
			cat n_11 = a+1, n_1L = 0;
			b -= a+1;
			cat d = (L == 1) ? 0 : min(n_11, b / (L-1));
			b -= (L-1) * d, n_11 -= d, n_1L += d;
			if(b) n_11--, b++;
			vector<group> V = {
				{L, 1, min_L1, 0},
				{k_a, 0, 1, 0},
				{1, 1, n_11, 1},
				{b, b?1:0, 1, 1},
				{L, 1, n_1L, 1}
			};
			build(ans, V, l, r);
		}
		else {
			cat k_a = (b%L) ? L : 0, k_b = b % L;
			a -= k_a, b -= k_b;
			b /= L;
			cat n_LL = 0, n_1L = b;
			a -= b;
			cat d = (L == 1) ? 0 : min(n_1L, a / (L-1));
			a -= d * (L-1), n_LL += d, n_1L -= d;
			cat n_mid = 0, k_mid = 0;
			if(n_1L) {
				n_mid++, n_1L--, k_mid = a+1;
				a = 0;
			}
			vector<group> V = {
				{L, 1, min_L1, 0},
				{k_a, k_b, 1, 0},
				{L, L, n_LL, 0},
				{k_mid, L, n_mid, 0},
				{1, L, n_1L, 0},
				{a, 1, 1, 0}
			};
			build(ans, V, l, r);
		}
		cout << ans << "\n";
	}
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 384