#include <bits/stdc++.h>

typedef long long ll;
int L, ML, MR, R, d;

// (a^d.b)^L . a^ML . b^MR . (a.b^d)^R
inline bool get(int pos) {
	return pos < (d + 1) * L ? pos % (d + 1) == d : (pos -= (d + 1) * L) < ML + MR ? pos >= ML : (pos - (ML + MR)) % (d + 1);
}

void solve(int n, int U, int l, int r, bool flip) {
	d = (n + U) / (n + 1);
	L = (d == 1 ? 0 : ((ll)d * n - U + d - 1) / ((ll)d * d - 1));
	n -= d * L, U -= L;
	R = std::min(n, U / d);
	ML = n - R, MR = U - d * R;
	flip ? ({for (; r >= l; --r) putchar(66 - get(r));}) : ({for (; l <= r; ++l) putchar(65 + get(l));});
	putchar(10);
}

void work() {
	int A, B, l, r;
	scanf("%d%d%d%d", &A, &B, &l, &r);
	A <= B ? solve(A, B, l - 1, r - 1, false) : solve(B, A, A + B - r, A + B - l, true);
}

int main() {
	int T;
	for (scanf("%d", &T); T; --T) work();
	return 0;
}