/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long llong;
#define int llong
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
string f(int h,int n,int l,int r){
	string s="",t="";
	if(h&&l==0&&r)s+="A",l++;
	if(!h&&r==n&&l!=n)t="B",r--;
	if(r-l>0)s+=string(r-l,'A'+h);
	return s+t;
}
signed main(){
	int q;
	cin>>q;
	while(q--){
		int a,b,L,R,k,l,r,ll,rr,t;
		cin>>a>>b>>L>>R;L--;
		k=(a+b)/(min(a,b)+1);
		l=0,r=min(a/k,b)+1;
		
		while(r-l>1){
			int h=(l+r)/2;
			if((a-h*k)*k+k-1>=b-h&&a-h*k>=0&&b-h>=0)l=h;
			else r=h;
		}
		
		t=l;

		l=min(L,t*(k+1)),r=min(R,t*(k+1));
		ll=l%(k+1),rr=r%(k+1);
		if(l==r);
		else if(ll<rr&&r-l<k+1)cout<<f(0,k+1,ll,rr);
		else{
			cout<<f(0,k+1,ll,k+1);
			rep(i,(r-l-(rr+k+1-ll))/(k+1))cout<<string(k,'A')+"B";
			cout<<f(0,k+1,0,rr);
		}
		
		a-=t*k;b-=t;
		t*=(k+1);

		int w=min(a,b/k);
		cout<<string(max(0ll,min(R,t+a-w)-max(L,t)),'A');
		t+=a-w;
		cout<<string(max(0ll,min(R,t+b-w*k)-max(L,t)),'B');
		t+=b-w*k;
		
		l=max(L,t),r=max(R,t);
		ll=(l-t)%(k+1),rr=(r-t)%(k+1);
		if(l==r);
		else if(ll<rr&&r-l<k+1)cout<<f(1,k+1,ll,rr);
		else{
			cout<<f(1,k+1,ll,k+1);
			rep(i,(r-l-(rr+k+1-ll))/(k+1))cout<<"A"+string(k,'B');
			cout<<f(1,k+1,0,rr);
		}
		cout<<endl;
		
	}
}















Measured memory_bytes: 384