#include <bits/stdc++.h>

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;

string solve(int a, int b, int gl, int gr) {
    if (a == b) {
        string s;
        for (int i = gl; i <= gr; ++i)
            s += "AB"[i % 2];
        return s;
    }

    if (a > b) {
        int s1, cnt1;
        if (a % (b+1) == 0) {
            s1 = a / (b+1);
            cnt1 = b+1;
        } else {
            s1 = a / (b+1) + 1;
            cnt1 = a % (b+1);
        }
        string s;
        for (int i = gl; i <= gr; ++i) {
            if (i < (s1+1)*cnt1) {
                if (i % (s1+1) == s1)
                    s += 'B';
                else
                    s += 'A';
            } else {
                int j = i - (s1+1)*cnt1;
                if (j % s1 == s1 - 1)
                    s += 'B';
                else
                    s += 'A';
            }
        }
        return s;
    } else {
        int cc = a + 1;
        int ms = (b + cc - 1) / cc;
        if (b % cc == 0) {
            string s;
            for (int i = gl; i <= gr; ++i) {
                if (i % (ms + 1) == ms)
                    s += 'A';
                else
                    s += 'B';
            }
            return s;
        }
        int lz = ms - 1;

        int wwl = 0, wwr = b + 1;
        while (wwl + 1 < wwr) {
            int ww = (wwl + wwr) / 2;
            int fr = cc - (ww + ms - 1) / ms;
            int rem = b - ww;
            if (rem + (rem+1LL)*lz >= fr)
                wwl = ww;
            else
                wwr = ww;
        }
        int ww = wwl;
        int wwcc = (ww + ms - 1) / ms;
        int rem = b - ww;
        int remcc = cc - wwcc;
        string s;
        for (int i = gl; i <= gr; ++i) {
            if (i < rem + remcc) {
                if (i % (ms + 1) == ms)
                    s += 'B';
                else
                    s += 'A';
            } else {
                int j = a + b - 1 - i;
                if (j % (ms + 1) == ms)
                    s += 'A';
                else
                    s += 'B';
            }
        }
        return s;
    }
}

string solve1(int a, int b, int gl, int gr) {
    if (a <= b)
        return solve(a, b, gl, gr);
    string s = solve(b, a, a+b-1-gr, a+b-1-gl);
    reverse(ALL(s));
    for (char &c : s)
        c = "AB"[c == 'A'];
    return s;
}

int main() {
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    while (q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << solve1(a, b, c - 1, d - 1) << "\n";
    }

    return 0;
}


Measured memory_bytes: 384