#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int q,kx,ax,bx,ql,qr;
bool ok(int nowa,int nowb) {
    if (nowa==0&&nowb==0) return 1;
    if (nowa==0||nowb==0) return 0;
    int lx=(nowa-1)/kx+1,rx=nowa;
    int lx2=(nowb-1)/kx+1,rx2=nowb;
    if (lx>rx2||rx<lx2) return 0;
    return 1;
}
bool ok2(int nowa,int nowb) {
    if (nowb==0) return 0;
    int lx=(nowa-1)/kx+1,rx=nowa;
    if (nowa==0) lx=0;
    int lx2=(nowb-1)/kx,rx2=nowb;
    if (lx>rx2||rx<lx2) return 0;
    return 1;
}
string print(int lp,int rp,int kk,char ch1,char ch2) {
    string s="";
    for (int i=lp;i<=rp;i++) {
        int l=1,r=i;
        bool judge=0;
        while (l<=r) {
            int mid=(l+r)/2;
            int gx=(mid-1)/kk*(kk+1)+(mid-1)%kk+1;
            if (gx==i) {
                s+=ch1;
                judge=1;
                break;
            }
            if (gx<i) l=mid+1;
            else r=mid-1;
        }
        if (!judge) s+=ch2;
    }
    return s;
}
void work() {
    if (!ok(ax,bx)) {
        char ch1='A',ch2='B';
        if (ax<bx) {
            swap(ch1,ch2);
            swap(ax,bx);
            int bqr=qr;
            qr=ax+bx+1-ql;
            ql=ax+bx+1-bqr;
        }
        int bnow;
        if (kx!=1) bnow=(ax-bx-1)/(kx-1);else bnow=0;
        string s=print(ql,min(qr,bnow*(kx+1)),kx,ch1,ch2);
        int xx;
        if (kx!=1) xx=(ax-bx-1)%(kx-1)+1;else xx=1;
        for (int i=max(bnow*(kx+1)+1,ql);i<=min(qr,bnow*(kx+1)+xx);i++) s+=ch1;
        int nowxx=bnow*(kx+1)+xx;
        s+=print(max(ql,nowxx+1)-nowxx,qr-nowxx,1,ch2,ch1);
        if (ch1=='A') cout<<s<<endl;
        else {
            int len=s.length();
            for (int i=len-1;i>=0;i--) putchar(s[i]);
            putchar('\n');
        }
        return;     
    }
    string s="";
    int l=0,r=(ax+bx)/(kx+1);
    while (l<r) {
        int mid=(l+r+1)/2;
        if (ok(ax-kx*mid,bx-mid)) l=mid;
        else r=mid-1;
    }
    int nowk=l*(kx+1);
    s+=print(ql,min(qr,nowk),kx,'A','B');
    int ap=ax-kx*l,bp=bx-l;
    int ll=1,rr=kx;
    while (ll<rr) {
        int mid=(ll+rr+1)/2;
        if (ok2(ap-mid,bp)) ll=mid;
        else rr=mid-1;
    }
    for (int i=max(ql,nowk+1);i<=min(nowk+ll,qr);i++) s+='A';
    int pg=bp%kx;
    if (pg==0) pg=kx;
    for (int i=max(nowk+ll+1,ql);i<=min(nowk+ll+pg,qr);i++) s+='B';
    ap-=ll;
    bp-=pg;
    l=0;
    r=min(bp/kx,ap/kx);
    while (l<r) {
        int mid=(l+r+1)/2;
        if (ok(ap-kx*mid,bp-kx*mid)) l=mid;
        else r=mid-1;
    }
    for (int i=max(nowk+ll+pg+1,ql);i<=min(nowk+ll+pg+kx*l,qr);i++) {
        int pk=(i-nowk+ll+pg-1)/kx+1;
        if (pk%2) s+='A';
        else s+='B';
    }
    ap-=kx*l;
    bp-=kx*l;
    nowk+=ll+pg+kx*l;
    int xr=ap-bp/kx+1;
    for (int i=max(nowk+1,ql);i<=min(nowk+xr,qr);i++) s+='A';
    for (int i=max(nowk+xr+1,ql);i<=min(nowk+xr+kx,qr);i++) s+='B';
    bp-=kx;
    s+=print(max(nowk+xr+kx+1,ql)-nowk-xr,qr-nowk-xr,kx,'B','A');
    cout<<s<<endl;
}
int main() {
    scanf("%d",&q);
    for (int i=1;i<=q;i++) {
        scanf("%d%d%d%d",&ax,&bx,&ql,&qr);
        kx=max((ax-1)/(bx+1)+1,(bx-1)/(ax+1)+1);
        work();
    }
    return 0;
}


Measured memory_bytes: 384