#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define int long long 
using namespace std;
const int N = 2e3 + 5;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
int T, n, k, a, b, c, d;
void solve() {
	a = read(); b = read(); c = read(); d = read(); n = a + b;
	int l = 0, r = n + 1, mid, A, B;
	k = (max(a, b) - 1) / (min(a, b) + 1) + 1;
	while(l < r) {
		mid = (l + r) >> 1;
		A = a - mid / (k + 1) * k - mid % (k + 1); B = b - mid / (k + 1);
		if(B <= A * k) l = mid + 1;
		else r = mid;
	}
	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(d, l); ++ i) putchar(i % (k + 1) ? 'A' : 'B');
	for(int i = max(c, l + 1); i <= d; ++ i) putchar((i - r) % (k + 1) ? 'B' : 'A');
	puts("");
}
signed main() {
	T = read(); while(T -- > 0) solve();
	fclose(stdin);
	fclose(stdout);
	return 0;
}