#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

LL A, B, C, D;

LL calc(LL a, LL b) {
	if (a < b)swap(a, b);
	b++;
	return (a + b - 1) / b;
}
LL f(LL a, LL b, LL aa, LL bb, LL maxlen) {
	LL lb = 0;
	LL ub = a + b + 1;
	while (ub - lb > 1) {
		const LL mid = (lb + ub) / 2;
		LL na = a - aa*mid;
		LL nb = b - bb*mid;
		if (na<0 || nb<0 || nb>maxlen*na || na - maxlen>maxlen*nb)ub = mid;
		else lb = mid;
	}
	return lb;
}
pair<LL, LL> g(LL a, LL b, LL maxlen) {
	LL lb = 0;
	LL ub = min(a, maxlen) + 1;
	while (ub - lb > 1) {
		const LL mid = (lb + ub) / 2;
		const LL na = a - mid;
		LL nb = min(b, maxlen*na);
		if (b - nb > maxlen)ub = mid;
		else lb = mid;
	}
	pair<LL, LL> ret = { lb,b - min(b, maxlen*(a - lb)) };
	if (lb > 0)chmax(ret.second, 1ll);
	return ret;
}
bool push(vector<pair<pair<LL, LL>, LL>>&x, pair<LL, LL> p, LL num) {
	if (p.first + p.second == 0)return false;
	if (num == 0)return false;
	x.push_back({ p, num });
	return true;
}
string solve() {
	LL c = C;
	LL d = D;
	c--;

	LL maxlen = calc(A, B);
	LL a = A, b = B;
	vector<pair<pair<LL, LL>, LL>> x;
	if (push(x, { 0ll,b - min(b,maxlen*a) }, 1ll)) {
		b -= x.front().first.second;
	}
	if (push(x, { maxlen,1ll }, f(a, b, maxlen, 1, maxlen))) {
		a -= x.back().first.first*x.back().second;
		b -= x.back().first.second*x.back().second;
	}
	if (push(x, g(a, b, maxlen), 1ll)) {
		a -= x.back().first.first*x.back().second;
		b -= x.back().first.second*x.back().second;
	}
	if (push(x, { maxlen,maxlen }, f(a, b, maxlen, maxlen, maxlen))) {
		a -= x.back().first.first*x.back().second;
		b -= x.back().first.second*x.back().second;
	}
	if (push(x, g(a, b, maxlen), 1ll)) {
		a -= x.back().first.first*x.back().second;
		b -= x.back().first.second*x.back().second;
	}
	if (push(x, { 1ll,maxlen }, f(a, b, 1, maxlen, maxlen))) {
		a -= x.back().first.first*x.back().second;
		b -= x.back().first.second*x.back().second;
	}
	int N = x.size();
	string ret = "";
	for (int i : range(N)) {
		LL num = x[i].first.first + x[i].first.second;
		LL k = min(x[i].second, c / num);
		c -= num*k;
		d -= num*k;
		x[i].second -= k;
		if (x[i].second>0)break;
	}
	for (int i : range(N)) {
		if (d == 0)break;
		LL num = x[i].first.first + x[i].first.second;
		while (d > 0 && x[i].second > 0) {
			if (c > 0) {
				LL aaa = min(c, x[i].first.first);
				c -= aaa; d -= aaa;
				LL bbb = min(c, x[i].first.second);
				c -= bbb; d -= bbb;
				for (int j : range(x[i].first.first - aaa)) {
					if (d > 0) {
						ret += "A"; d--;
					}
					else break;
				}
				for (int j : range(x[i].first.second - bbb)) {
					if (d > 0) {
						ret += "B"; d--;
					}
					else break;
				}
			}
			else {
				for (int j : range(x[i].first.first)) {
					if (d > 0) {
						ret += "A"; d--;
					}
					else break;
				}
				for (int j : range(x[i].first.second)) {
					if (d > 0) {
						ret += "B"; d--;
					}
					else break;
				}
			}
			x[i].second--;
		}
	}
	return ret;
}

int main() {
	int Q;
	cin >> Q;
	for (int i : range(Q)) {
		cin >> A >> B >> C >> D; cout <<solve() << endl;;
	}

	return 0;
}


Measured memory_bytes: 384