#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
bool check(int a,int b,int mid,int k)
{
    if ((long long)mid*k>a) return false;
    a-=mid*k;
    b-=(mid-1);
    if (b>((long long)(a+1)*k)) return false;
    return true;
}
void get_ans(int a,int b,int c,int d,int k)
{
    // k 'a' 1 'b' ..... until it doesn't work
    int l=1,r=a;
    for (;l<=r;)
    {
        int mid=(l+r)/2;
        if (check(a,b,mid,k)) l=mid+1; else r=mid-1;
    }
    int ans=r;
    if (ans!=0)
    {
        int t=ans*(k+1);
        if (c<t)
        {
            int i;
            for (i=c;i<d;i++)
            {
                if (i>=t) break;
                if (i%(k+1)==k)
                {
                    putchar('B');
                }
                else
                {
                    putchar('A');
                }
            }
            c=i;
            if (c>=d)
            {
                putchar('\n');
                return;
            }
        }
        c-=t;
        d-=t;
        a-=ans*k;
        b-=ans;
    }
    int need_a=b/k;
    if (b%k==0) need_a--;
    //We need only need_a 'a'
    int t=a-need_a;
    if (c<t)
    {
        int i;
        for (i=c;i<d;i++)
        {
            if (i>=t) break;
            putchar('A');
        }
        c=i;
        if (c>=d)
        {
            putchar('\n');
            return;
        }
    }
    c-=t;
    d-=t;
    a-=t;
    //We can do first bs
    t=b%k;
    if (t==0)
    {
        t=k;
    }
    if (c<t)
    {
        int i;
        for (i=c;i<d;i++)
        {
            if (i>=t) break;
            putchar('B');
        }
        c=i;
        if (c>=d)
        {
            putchar('\n');
            return;
        }
    }
    c-=t;
    d-=t;
    b-=t;
    int i;
    for (i=c;i<d;i++)
    {
        if (i%(k+1)!=0)
        {
            putchar('B');
        }
        else
        {
            putchar('A');
        }
    }
    putchar('\n');
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int q;
    scanf("%d",&q);
    int i;
    for (i=0;i<q;i++)
    {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        c--;
        if (a>=b)
        {
            //a is more than b!
            /*
            if (a==b)
            {
                int j;
                for (j=c;j<d;j++)
                {
                    if (j%2==0) putchar('A'); else putchar('B');
                }
                putchar('\n');
                continue;
            }
            */
            int k=a/(b+1);
            if (a%(b+1)!=0) k++;
            //at most k 'a' is here.
            //so we have the first ones get k 'a'
            //if t == 0 : No Special ones
            get_ans(a,b,c,d,k);
        }
        else
        {
            int k=b/(a+1);
            if (b%(a+1)!=0) k++;
            get_ans(a,b,c,d,k);
        }
    }
    return 0;
} 


Measured memory_bytes: 384