#include <bits/stdc++.h>
    using namespace std;
    string ret = "";
    void adda(int x){
        while(x--) ret.push_back('A');
    }
    void addb(int x){
        while(x--) ret.push_back('B');
    }
    bool intersect_real(pair<int, int> a, pair<int, int> b){
        return a.first <= b.second && b.first <= a.second;
    }
    bool intersect(pair<int, int> a, pair<int, int> b, int x){
        if(intersect_real(a, b)) return true;
        if(x != -1) if(intersect_real({a.first + 1, a.second + 1}, b)) return true;
        if(x != 1) if(intersect_real(a, {b.first + 1, b.second + 1})) return true;
        return false;
    }
    bool solveable(int k, int a, int b, int x){
        if(a < 0 || b < 0) return false;
        pair<int, int> ap = {(a + k - 1) / k, a};
        pair<int, int> bp = {(b + k - 1) / k, b};
        return intersect(ap, bp, x);
    }
    void solve(int a, int b, int c, int d){
        ret = "";
        int k = -1;
        int lo = 1, hi = max(a, b);
        while(lo <= hi){
            int md = (lo + hi) / 2;
            pair<int, int> ap = {(a + md - 1) / md, a};
            pair<int, int> bp = {(b + md - 1) / md, b};
            if(intersect(ap, bp, 0)) {
                k = md;
                hi = md - 1;
            } else lo = md + 1;
        }
        int aor = a, bor = b;
        lo = 1;
        hi = a / k;
        int ans = 0;
        while(lo <= hi){
            int md = (lo + hi) / 2;
            if(solveable(k, a - md * k, b - (md), -1)) {
                ans = md;
                lo = md + 1;
            } else hi = md - 1;
        }
        int ANS1 = ans;
        a -= ans * k;
        b -= ans;
        ans = 0;
        lo = 1;
        hi = b / k;
        while(lo <= hi){
            int md = (lo + hi) / 2;
            if(solveable(k, a - md, b - (md * k), 1)) {
                ans = md;
                lo = md + 1;
            } else hi = md - 1;
        }
        int ANS2 = ans;
        a -= ans;
        b -= ans * k;
        //deque<string> p;
        //string f;
        //for(int i = 0; i < k; i++) f.push_back('A');
        //f.push_back('B');
        //string fs;
        //fs.push_back('A');
        //string mid;
        /*for(int i = 0; i < k; i++) fs.push_back('B');
        for(int i = 0; i < ANS1; i++) cout << f;
        cout <<  "|";*/
        /*while(a--) mid.push_back('A');
        while(b--) mid.push_back('B');*/
        /*cout << "|";
        for(int i = 0; i < ANS2; i++) cout << fs;*/
        //cout << endl;
        for(int p = c - 1; p <= d - 1; p++){
            int p2 = p;
            //printf("%d\n", p);
            if(p2 < (k + 1) * ANS1){
                //printf("USAO 1");
                p2 %= (k + 1);
                if(p2 == k) printf("B");
                else printf("A");
            } else {
                p2 -= (k + 1) * ANS1;
                //printf("USAO 2");
                if(p2 < a) printf("%c", 'A');
                else {
                    p2 -= a;
                    if(p2 < b) printf("%c", 'B');
                    else {
                        p2 -= b;
                        p2 %= (k + 1);
                        if(p2 == 0) printf("A");
                        else printf("B");
                    }
                }
            }
        }
        printf("\n");
    }
    int main(){
        int t;
        scanf("%d", &t);
        while(t--){
            int a, b, c, d;
            scanf("%d %d %d %d", &a, &b, &c, &d);
            solve(a, b, c, d);
        }
        return 0;
    }


Measured memory_bytes: 384