#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int Q;
ll A, B, leftb, rightb;
ll U, N, M, alpha, beta, L;

void pre() {
	U = (A + B) / (B + 1);
	if(A == B) {
		N = B; M = 0; alpha = 0; beta = 0; L = 0;
		return;
	}
	if(A - U * B > 0) {
		N = B;
		M = 0;
		alpha = 0;
		beta = 0;
		L = A - U * B;
	}
	else {
		ll lv = 0, rv = (A + B) / (U + 1) + 10;
		while(rv - lv > 1) {
			ll m = (lv + rv) / 2;
			if(A - (U * m + (B - 1 - m) / U) > 0) lv = m;
			else rv = m;
		}
		N = lv;
		M = (B - 1 - N) / U;
		alpha = A - (U * N + M);
		beta = B - (N + U * M);
		L = 0;
	}
}

string F(ll lv, ll rv) {
	string res = "";
	for(ll i = lv; i < rv; i++) {
		if(i % (U + 1) == U) res += 'B';
		else res += 'A';
	}
	return res;
}

string G(ll lv, ll rv) {
	string res = "";
	for(ll i = lv; i < rv; i++) {
		if(i < alpha) res += 'A';
		else res += 'B';
	}
	return res;
}

string H(ll lv, ll rv) {
	string res = "";
	for(ll i = lv; i < rv; i++) {
		if(i % (U + 1) == 0) res += 'A';
		else res += 'B';
	}
	return res;
}

string I(ll lv, ll rv) {
	string res = "";
	for(ll i = lv; i < rv; i++) {
		res += 'A';
	}
	return res;
}

string pre2() {
	ll bd0 = 0; ll bd1 = (U + 1) * N; ll bd2 = (U + 1) * N + alpha + beta;
	ll bd3 = (A + B - L); ll bd4 = A + B;
	// debug(U, N, M, alpha, beta, L);
	// debug(bd0, bd1, bd2, bd3);
	string res = "";
	res += F(max(bd0, leftb) - bd0, min(bd1, rightb) - bd0);
	res += G(max(bd1, leftb) - bd1, min(bd2, rightb) - bd1);
	res += H(max(bd2, leftb) - bd2, min(bd3, rightb) - bd2);
	res += I(max(bd3, leftb) - bd3, min(bd4, rightb) - bd3);
	return res;
}

string sub_solve() {
	bool swaped = false;
	if(B > A) {
		swaped = true;
		swap(A, B);
		leftb = (A + B - 1) - leftb;
		rightb = (A + B - 1) - rightb;
		swap(leftb, rightb);
		rightb++;
	}
	else rightb++;
	pre();
	string res = pre2();
	if(swaped) {
		reverse(all(res));
		rep(i, 0, sz(res)) {
			if(res[i] == 'A') res[i] = 'B';
			else res[i] = 'A';
		}
	}
	return res;
}

void solve() {
	cin >> Q;
	while(Q--) {
		cin >> A >> B >> leftb >> rightb; leftb--; rightb--;
		cout << sub_solve() << "\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 384