#include<bits/stdc++.h>
#define fo(i, x, y) for(ll i = x, _b = y; i <= _b; i ++)
#define ff(i, x, y) for(ll i = x, _b = y; i <  _b; i ++)
#define fd(i, x, y) for(ll i = x, _b = y; i >= _b; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

#define pc putchar

ll T, a, b, c, d;

ll divs(ll x, ll y) {
	return x / y + (x % y != 0);
}

int main() {
	for(scanf("%lld", &T); T; T --) {
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		ll as = a + b + 1; ll k = divs(max(a, b), min(a, b) + 1);
		for(ll l = 0, r = a + b; l <= r; ) {
			ll m = l + r >> 1;
			ll t = m / (k + 1);
			ll a0 = a - t * k - m % (k + 1);
			ll b0 = b - t;
			if(b0 <= a0 * k) l = m + 1; else r = m - 1, as = m;
		}
		ll t = as / (k + 1);
		ll a0 = a - t * k - as % (k + 1);
		ll b0 = b - t;
		ll nas = as + b0 - a0 * k + 1;
		fo(i, c, d) {
			ll x = i;
			if(x <= as) {
				pc(x % (k + 1) == 0 ? 'B' : 'A');
			} else {
				x -= nas;
				pc(x % (k + 1) == 0 ? 'A' : 'B');
			}
		}
		pc('\n');
	}
}
