#include <bits/stdc++.h>

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

#define int long long

string get(int a, int b, int c, int d) {
	string s = "";
	if (a == b || a == b + 1) {
		for (int i = c; i <= d; ++i) {
			s += (char)('B' - i % 2);
		}
		return s;
	} else if (a + 1 == b) {
		for (int i = c; i <= d; ++i) {
			s += (char)('A' + i % 2);
		}
		return s;
	}

	int ss = (a + b) / (min(a, b) + 1);
	if (1ll * a * ss < b) {
		int num_left_bs = b - a * ss;
		while (c <= d) {
			if (c <= num_left_bs) {
				s += 'B';
			} else {
				int x = (c - num_left_bs - 1) % (ss + 1);
				if (x == 0) {
					s += 'A';
				} else {
					s += 'B';
				}
			}
			++c;
		}
		return s;
	}

	int l = (max(a, b) + ss - 1) / ss, r = min(a, b) + 1;
	while (l + 1 < r) {
		int k = (l + r) / 2;
		int num_a = (a - k) / (ss - 1);
		int num_b = (b - k) / (ss - 1);
		if (num_a + num_b >= k - 1) {
			l = k;
		} else {
			r = k;
		}
	}

	int k = l;

	// cerr << k << " " << ss << "\n";

	vector<array<int, 3>> ev;
	ev.push_back({(a - k) / (ss - 1), ((a - k) % (ss - 1)) + 1, 0});
	ev.push_back({(a - k) / (ss - 1) + 1, 1, 0});
	ev.push_back({k - (b - k) / (ss - 1), ss, 1});
	ev.push_back({k - (b - k) / (ss - 1) - 1, ((b - k) % (ss - 1)) + 1, 1});
	ev.push_back({a + b, 1, 0});

	sort(all(ev));
	int cnt[2] = {ss, 1};
	int cur = 0;
	int lst = 0;

	// cerr << k << " " << ss << "\n";
	// for (auto v : ev) {
	// 	cerr << v[0] << " " << v[1] << " " << v[2] << "\n";
	// }

	for (int i = 0; i < (int)ev.size(); ++i) {
		int new_cur = cur + (ev[i][0] - lst) * (cnt[0] + cnt[1]);
		if (new_cur >= c) {
			while (c <= d) {
				int j = (c - cur - 1) % (cnt[0] + cnt[1]);
				if (j < cnt[0]) {
					s += 'A';
				} else {
					s += 'B';
				}

				if (c++ == new_cur) {
					cur = new_cur;
					lst = ev[i][0];
					cnt[ev[i][2]] = ev[i][1];

					i += 1;
					new_cur = 2e9;
					while (i < (int)ev.size() && ev[i][0] == lst) {
						cnt[ev[i][2]] = ev[i][1];
						i += 1;
					}

					if (i < (int)ev.size()) {
						new_cur = cur + (ev[i][0] - lst) * (cnt[0] + cnt[1]);
					}
				}
			}

			break;
		} else {
			cur = new_cur;
			lst = ev[i][0];
			cnt[ev[i][2]] = ev[i][1];
		}
	}

	if (0) {
		if (k > (max(a, b) + ss - 1) / ss) {
			k -= 1;
			string t = s;
			s = "";

			vector<array<int, 3>> ev;
			ev.push_back({(a - k) / (ss - 1), ((a - k) % (ss - 1)) + 1, 0});
			ev.push_back({(a - k) / (ss - 1) + 1, 1, 0});
			ev.push_back({k - (b - k) / (ss - 1), ss, 1});
			ev.push_back({k - (b - k) / (ss - 1) - 1, ((b - k) % (ss - 1)) + 1, 1});

			sort(all(ev));
			int cnt[2] = {ss, 1};
			int cur = 0;
			int lst = 0;

			for (int i = 0; i < (int)ev.size(); ++i) {
				int new_cur = cur + (ev[i][0] - lst) * (cnt[0] + cnt[1]);
				if (new_cur >= c) {
					while (c <= d) {
						int j = (c - cur - 1) % (cnt[0] + cnt[1]);
						if (j < cnt[0]) {
							s += 'A';
						} else {
							s += 'B';
						}

						if (c++ == new_cur) {
							cur = new_cur;
							lst = ev[i][0];
							cnt[ev[i][2]] = ev[i][1];

							i += 1;
							new_cur = 2e9;
							while (i < (int)ev.size() && ev[i][0] == lst) {
								cnt[ev[i][2]] = ev[i][1];
								i += 1;
							}

							if (i < (int)ev.size()) {
								new_cur = cur + (ev[i][0] - lst) * (cnt[0] + cnt[1]);
							}
						}
					}

					break;
				} else {
					cur = new_cur;
					lst = ev[i][0];
					cnt[ev[i][2]] = ev[i][1];
				}
			}

			if (t <= s) {
				cerr << a << " " << b << "\n";
				cerr << s << " " << t << "\n";
				assert(0);
			}

			s = t;

			k += 1;
		}
	}

	if (0) {
		if (k < min(a, b) + 1) {
			k += 1;
			string t = s;
			s = "";

			vector<array<int, 3>> ev;
			ev.push_back({(a - k) / (ss - 1), ((a - k) % (ss - 1)) + 1, 0});
			ev.push_back({(a - k) / (ss - 1) + 1, 1, 0});
			ev.push_back({k - (b - k) / (ss - 1), ss, 1});
			ev.push_back({k - (b - k) / (ss - 1) - 1, ((b - k) % (ss - 1)) + 1, 1});

			sort(all(ev));
			int cnt[2] = {ss, 1};
			int cur = 0;
			int lst = 0;

			for (int i = 0; i < (int)ev.size(); ++i) {
				int new_cur = cur + (ev[i][0] - lst) * (cnt[0] + cnt[1]);
				if (new_cur >= c) {
					while (c <= d) {
						int j = (c - cur - 1) % (cnt[0] + cnt[1]);
						if (j < cnt[0]) {
							s += 'A';
						} else {
							s += 'B';
						}

						if (c++ == new_cur) {
							cur = new_cur;
							lst = ev[i][0];
							cnt[ev[i][2]] = ev[i][1];

							i += 1;
							new_cur = 2e9;
							while (i < (int)ev.size() && ev[i][0] == lst) {
								cnt[ev[i][2]] = ev[i][1];
								i += 1;
							}

							if (i < (int)ev.size()) {
								new_cur = cur + (ev[i][0] - lst) * (cnt[0] + cnt[1]);
							}
						}
					}

					break;
				} else {
					cur = new_cur;
					lst = ev[i][0];
					cnt[ev[i][2]] = ev[i][1];
				}
			}

			if (t <= s) {
				cerr << a << " " << b << "\n";
				cerr << s << " " << t << "\n";
				assert(0);
			}

			s = t;

			k -= 1;
		}
	}

	return s;

/*	int ss = (a + b) / (b + 1);
	int k = (a + ss - 1) / ss;

	int bb = b - k;
	int num_s = bb / (ss - 1);
	int rest = bb % (ss - 1);

	// first k - 1 blocks have s 'a's
	// last block has ((a - k) % (s - 1)) + 1 'a's

	// last num_s blocks have s 'b's
	// next block before has rest + 1 'b's
	// all other blocks have 1 'b'

	vector<array<int, 3>> ev;
	// ev.push_back({(a + ss - 1) / ss, ((a - k) % (ss - 1)) + 1, 0});
	ev.push_back({(a - k) / (ss - 1), ((a - k) % (ss - 1)) + 1, 0});
	ev.push_back({k - num_s, ss, 1});
	ev.push_back({k - num_s - 1, rest + 1, 1});

	sort(all(ev));

	// for (auto v : ev) {
	// 	cerr << v[0] << " " << v[1] << " " << v[2] << "\n";
	// }

	int cnt[2] = {ss, 1};
	int cur = 0;
	int lst = 0;

	for (int i = 0; i < (int)ev.size(); ++i) {
		int new_cur = cur + (ev[i][0] - lst) * (cnt[0] + cnt[1]);
		if (new_cur >= c) {
			while (c <= d) {
				int j = (c - cur - 1) % (cnt[0] + cnt[1]);
				if (j < cnt[0]) {
					s += 'A';
				} else {
					s += 'B';
				}

				if (c++ == new_cur) {
					cur = new_cur;
					lst = ev[i][0];
					cnt[ev[i][2]] = ev[i][1];

					i += 1;
					new_cur = 2e9;
					while (i < (int)ev.size() && ev[i][0] == lst) {
						cnt[ev[i][2]] = ev[i][1];
						i += 1;
					}

					if (i < (int)ev.size()) {
						new_cur = cur + (ev[i][0] - lst) * (cnt[0] + cnt[1]);
					}
				}
			}

			return s;
		} else {
			cur = new_cur;
			lst = ev[i][0];
			cnt[ev[i][2]] = ev[i][1];
		}
	}
	return "";*/
}

void solve() {
	int a = nxt(), b = nxt(), c = nxt(), d = nxt();
	puts(get(a, b, c, d).c_str());
}

int32_t main() {
	// while (true) {
	// 	int a = rand() % 10 + 1;
	// 	int b = rand() % 10 + 1;
	// 	auto s = get(a, b, 1, a + b);
	// 	int c = rand() % (a + b);
	// 	int d = rand() % (a + b);
	// 	if (c > d) {
	// 		swap(c, d);
	// 	}
	// 	auto t = get(a, b, c + 1, d + 1);
	// 	if (s.find("BBAA") != string::npos || t != s.substr(c, d - c + 1)) {
	// 		cerr << "\n";
	// 		cerr << a << " " << b << " " << c + 1 << " " << d + 1 << " '" << s << "' '" << t << "'\n";
	// 		return 0;
	// 	} else {
	// 		cerr << "q";
	// 	}
	// }

	int T = nxt();
	while (T--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 384