#include <bits/stdc++.h>

using namespace std;

int main() {
	int Q, A, B, C, D;
	scanf("%d", &Q);
	while (Q--) {
		scanf("%d%d%d%d", &A, &B, &C, &D);
		int len = (max(A, B) - 1) / (min(A, B) + 1) + 1;
		int l = 0, r = A + B;
		while (l < r) {
			int mid = l + r >> 1;
			int cb = mid / (len + 1), ca = mid - cb;
			ca = A - ca, cb = B - cb;
			if (cb <= 1ll * ca * len) l = mid + 1;
			else r = mid;
		}
		int cb = l / (len + 1), ca = l - cb;
		ca = A - ca, cb = B - cb;
		int bg = l + 1 - (len - (cb - ca * len));
		for (int i = C; i <= D; ++i)
			if (i <= l) putchar("AB"[(i - 1) % (len + 1) == len]);
			else putchar("BA"[(i - bg) % (len + 1) == len]);
		puts("");
	}
	return 0;
}
