#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ii getrange(ll a, ll r)
{
	return mp((a+r-1)/r - 1, (a+1)*r);
}

string solve(ll a, ll b, ll l, ll r)
{
	if(abs(a-b)<=1)
	{
		string s="";
		for(ll i=l;i<=r;i++)
		{
			if(i%2==0) 
			{
				if(b>a) s+="B";
				else s+="A";
			}
			else
			{
				if(b>a) s+="A";
				else s+="B";
			}
		}
		return s;
	}
	ll run = 0;
	{
		ll lo = 1; ll hi = max(a,b);
		while(lo<=hi)
		{
			ll mid=(lo+hi)>>1;
			ii rangeb = getrange(a,mid);
			ii rangea = getrange(b,mid);
			if(rangeb.fi<=b&&b<=rangeb.se&&rangea.fi<=a&&a<=rangea.se)
			{
				run=mid;hi=mid-1;
			}
			else lo=mid+1;
		}
	}
	assert(run>1);
	{
		//r_0Br_1B...r_{b-1}Br_b
		ll ansr=0;
		{
			ll lo = 1; ll hi = b+1;
			while(lo<=hi)
			{
				ll mid=(lo+hi)>>1;
				//r_0 to r_{mid-1} becomes run
				ll rema = a - mid*run;
				ll remb = b - mid;
				bool pos=0;
				if(rema>=0&&remb>=0)
				{
					//start with B
					ll minb = (rema+run-1)/run - 1;
					ll maxb = run*(rema+1)-1;
					if(remb>=minb&&remb<=maxb) pos=1;
				}
				if(pos)
				{
					ansr=mid; lo=mid+1;
				}
				else
				{
					hi=mid-1;
				}
			}
		}
		//cerr<<"ANSR : "<<ansr<<'\n';
		//ansr copies of run
		//(run,A),(1,B),(run,A),(1,B),.... (for ansr times)
		a-=ansr*run; b-=ansr;
		ll ansm=0;
		if(b==0) ansm=a;
		else
		{
			ll lo = 1; ll hi = run;
			while(lo<=hi)
			{
				ll mid=(lo+hi)>>1;
				//r_{ansr} becomes mid
				ll rema = a - mid;
				ll remb = b - 1;
				bool pos=0;
				if(rema>=0&&remb>=0)
				{
					//start with B
					ll minb = (rema+run-1)/run - 1;
					ll maxb = run*(rema+1)-1;
					if(remb>=minb&&remb<=maxb) pos=1;
				}
				if(pos)
				{
					ansm=mid; lo=mid+1;
				}
				else
				{
					hi=mid-1;
				}
			}
		}
		a-=ansm;
		//start with B
		//# of BABABABA
		ll bacopies=0;
		{
			ll lo = 1; ll hi = a;
			while(lo<=hi)
			{
				ll mid=(lo+hi)>>1;
				ll rema = a - mid;
				ll remb = b - mid;
				bool pos=0;
				if(rema>=0&&remb>=0)
				{
					//start with A
					ll mina = (remb+run-1)/run - 1;
					ll maxa = run*(remb+1)-1;
					if(rema>=mina&&rema<=maxa) pos=1;
				}
				if(pos)
				{
					bacopies=mid; lo=mid+1;
				}
				else
				{
					hi=mid-1;
				}
			}
		}
		a-=bacopies; b-=bacopies;
		ll blen=0;
		//I have a+1 slots left _A_A_A_A_
		blen = b - a*run;
		string s;
		for(ll i=l;i<=r;i++)
		{
			//cerr<<run+1<<' '<<ansr<<'\n';
			if(i<(run+1)*ansr)
			{
				if(i%(run+1)==run) s+="B";
				else s+="A";
				continue;
			}
			ll ileft = i - (run+1)*ansr;
			if(ileft<ansm+1)
			{
				if(ileft<ansm) s+="A";
				else s+="B";
				continue;
			}
			ileft-=ansm;
			if(ileft<2*bacopies)
			{
				if(ileft%2==0) s+="B";
				else s+="A";
				continue;
			}
			ileft-=2*bacopies;
			if(ileft<blen)
			{
				s+="B"; continue;
			}
			ileft-=blen;
			if(ileft%(run+1)==0) s+="A";
			else s+="B";
		}
		return s;
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int q; cin>>q;
	while(q--)
	{
		int a,b,l,r;
		cin>>a>>b>>l>>r;
		l--; r--;
		string s = solve(a,b,l,r);
		cout<<s<<'\n';
	}
}


Measured memory_bytes: 384