#include <bits/stdc++.h>

using namespace std;

using ll = long long;

/*
string solve(int a, int b) {
    string res = "";
    if (a >= b) {
        int max_len = (a + b) / (b + 1);
        string tmp = string(max_len, 'A') + "B";
        int cnt = min(a / max_len, b);
        for (int i = 0; i < cnt; i++) {
            res += tmp;
        }
        res += string(a - cnt * max_len, 'A') + string(b - cnt, 'B');
    } else {
        int max_len = (a + b) / (a + 1);
        string tmp = string(max_len, 'B') + "A";
        int cnt = min(b / max_len, a);
        for (int i = 0; i < cnt; i++) {
            res += tmp;
        }
        res += string(b - cnt * max_len, 'B') + string(a - cnt, 'A');
        reverse(res.begin(), res.end());
    }
    return res;
}*/

string solve(int a, int b, int max_len) {
    if (b == 0) return string(a, 'A');
    if (a == 0) return string(b, 'B');
    if (a >= b) {
        if (max_len == -1) max_len = (a + b) / (b + 1);
        if (a < max_len) return string(a, 'A') + string(b, 'B');
        return string(max_len, 'A') + "B" + solve(a - max_len, b - 1, max_len);
    } else {
        if (max_len == -1) max_len = (a + b) / (a + 1);
        if (b < max_len) return string(a, 'A') + string(b, 'B');
        return solve(a - 1, b - max_len, max_len) + "A" + string(max_len, 'B');
    }
}

string solve(int a, int b, int c, int d) {
    //int ca = a, cb = b;
    int max_len, cnt_a = 0, cnt_b = 0;
    if (a >= b) {
        max_len = (a + b) / (b + 1);
        cnt_a = min({(a + b) / (max_len + 1), a / max_len, b});
        if (max_len > 1) cnt_a = min((a - b) / (max_len - 1), cnt_a);
        a -= cnt_a * max_len;
        b -= cnt_a;
    } else {
        max_len = (a + b) / (a + 1);
        cnt_b = min({(a + b) / (max_len + 1), b / max_len, a});
        if (max_len > 1) cnt_b = min((b - a) / (max_len - 1), cnt_b);
        b -= cnt_b * max_len;
        a -= cnt_b;
    }
    
    //assert(a + cnt_a * max_len + cnt_b == ca && b + cnt_b * max_len + cnt_a == cb);

    int tmp = min(b / (max_len + 1), a / (max_len + 1));
    cnt_a += tmp;
    cnt_b += tmp;
    a -= tmp * (max_len + 1);
    b -= tmp * (max_len + 1);

    //assert(a <= max_len || b <= max_len);

    if (a >= b) {
        int tmp2 = min(a / max_len, b);
        cnt_a += tmp2;
        a -= tmp2 * max_len;
        b -= tmp2;
    } else {
        int tmp2 = min(b / max_len, a);
        cnt_b += tmp2;
        b -= tmp2 * max_len;
        a -= tmp2;
    }

    //assert(a <= max_len && b <= max_len);

    string res = "";
    for (int i = c; i < d; i++) {
        if (i < cnt_a * (max_len + 1)) {
            int idx = i % (max_len + 1);
            res += (idx == max_len ? 'B' : 'A');
        } else if (i < cnt_a * (max_len + 1) + a) {
            res += 'A';
        } else if (i < cnt_a * (max_len + 1) + a + b) {
            res += 'B';
        } else {
            int idx = (i - cnt_a * (max_len + 1) - a - b) % (max_len + 1);
            res += (idx == 0 ? 'A' : 'B');
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        //assert(a <= 1000 && b <= 1000);
        c--;
        cout << solve(a, b, c, d) << endl;
    }
    return 0;
}

Measured memory_bytes: 384