#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;
const unsigned gen_seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);

#define all(c) (c).begin(),(c).end()
#define forn(i, a, b) for(int i = a; i < b; i++)
#define read(x) scanf("%d", &x)
#define readv(x, n) vi x(n); forn(i,0,n) scanf("%d", &x[i])

#define pb push_back
#define mp make_pair

string get(int a, int b) {
    ll k = max((a+b)/(a+1), (a+b)/(b+1));
    ll x;
    if(k==1) {
        if(a >= b) x = b;
        else x = 0;
    }
    else {
        x = (k*(a+1)-b-1)/(k*k-1);
    }
    if(x > a/k) x = a/k;
    if(x > b) x = b;
    ll r = (k*(a+1)-b - x*(k*k-1))/k;
    if(r<0) r = 0;
    if(k==1) {
        r = 0;
        if(a>b) r = 1;
    }
    int lb = b-x;
    int la = a-x*k-r;
    int tail = lb%k;
    if(tail ==0) tail = k;
    string res;
    forn(j,1,a+b+1) {
        if(j <= (k+1)*x + r) {
            if(j%(k+1) == 0) res.pb('B');
            else res.pb('A');
        }
        else {
            int pos = j-(k+1)*x-r;
            if(pos <= tail) res.pb('B');
            else {
                pos -= tail+1;
                if(pos%(k+1) == 0) res.pb('A');
                else res.pb('B');
            }
        }
    }
    return res;
}

string get2(int a, int b) {
    ll k = max((a+b)/(a+1), (a+b)/(b+1));
    int na = 0;
    int nb = 0;
    string res;
    while(a>0 || b>0) {
        if(a==0) {
            res.pb('B');
            b--;
        }
        else if(b==0) {
            res.pb('A');
            a--;
        }
        else if(na == k) {
            na = 0; nb=1;
            res.pb('B');
            b--;
        }
        else if(nb==k) {
            nb = 0; na=1;
            res.pb('A');
            a--;
        }
        else {
            a--;
            ll k2 = max((a+b)/(a+1), (a+b)/(b+1));
            a++;
            if(k2 <= k) {
                nb = 0;
                na++;
                res.pb('A');
                a--;
            }
            else {
                na = 0;
                nb ++;
                res.pb('B');
                b--;
            }
        }
    }
    return res;
}

int main()
{
//    forn(i,1,30) forn(j,1,30) {
//        if(get(i,j) != get2(i,j)) {
//            cout<<i<<' '<<j<<' '<<get(i,j) <<' '<<get2(i,j)<<endl;
//        }
//    }
    int q;
    scanf("%d", &q);
    forn(i,0,q) {
        int a,b,c,d;
        scanf("%d %d %d %d", &a, &b, &c, &d);
        ll k = max((a+b)/(a+1), (a+b)/(b+1));
        ll x;
        if(k==1) {
            if(a >= b) x = b;
            else x = 0;
        }
        else {
            x = (k*(a+1)-b-1)/(k*k-1);
        }
        if(x > a/k) x = a/k;
        if(x > b) x = b;
        ll r = (k*(a+1)-b - x*(k*k-1))/k;
        if(r<0) r = 0;
        if(k==1) {
            r = 0;
            if(a>b) r = 1;
        }
        int lb = b-x;
        int la = a-x*k-r;
        int tail = lb%k;
        if(tail ==0) tail = k;
        forn(j,c,d+1) {
            if(j <= (k+1)*x + r) {
                if(j%(k+1) == 0) printf("B");
                else printf("A");
            }
            else {
                int pos = j-(k+1)*x-r;
                if(pos <= tail) printf("B");
                else {
                    pos -= tail+1;
                    if(pos%(k+1) == 0) printf("A");
                    else printf("B");
                }
            }
        }
        printf("\n");
    }
    
}


Measured memory_bytes: 384