// Original C++ solution (slower):
#include <map>

#include <set>

#include <ctime>

#include <queue>

#include <stack>

#include <cmath>

#include <vector>

#include <bitset>

#include <cstdio>

#include <cctype>

#include <string>

#include <numeric>

#include <cstring>

#include <cassert>

#include <climits>

#include <cstdlib>

#include <iostream>

#include <algorithm>

#include <functional>

using namespace std ;

//#define int long long

#define rep(i, a, b) for (int i = (a); i <= (b); i++)

#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)

#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)

#define clr(a) memset(a, 0, sizeof(a))

#define ass(a, sum) memset(a, sum, sizeof(a))

#define lowbit(x) (x & -x)

#define all(x) x.begin(), x.end()

#define ub upper_bound

#define lb lower_bound

#define pq priority_queue

#define mp make_pair

#define pb push_back

#define pof pop_front

#define pob pop_back

#define fi first

#define se second

#define iv inline void

#define enter cout << endl

#define siz(x) ((int)x.size())

#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)

typedef long long ll ;

typedef unsigned long long ull ;

typedef pair <int, int> pii ;

typedef vector <int> vi ;

typedef vector <pii> vii ;

typedef queue <int> qi ;

typedef queue <pii> qii ;

typedef set <int> si ;

typedef map <int, int> mii ;

typedef map <string, int> msi ;

const int N = 100010 ;

const int INF = 0x3f3f3f3f ;

const int iinf = 1 << 30 ;

const ll linf = 2e18 ;

const int MOD = 1000000007 ;

const double eps = 1e-7 ;

void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

template <class T> void print(T a) { cout << a << endl ; exit(0) ; }

template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }

template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }

template <class T> void upd(T &a, T b) { (a += b) %= MOD ; }

template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }



int T, a, b, c, d, x ;



bool check(int mid) {

	int cb = mid / (x + 1) ;

	int ca = mid - cb ;

	if (b - cb > 1ll * (a - ca) * x) return 1 ;

	else return 0 ;

}



signed main(){

//	file("test") ;

	scanf("%d", &T) ;

	while (T--) {

		scanf("%d%d%d%d", &a, &b, &c, &d) ;

		x = (max(a, b) - 1) / (min(a, b) + 1) + 1 ;

		int l = 0, r = a + b, pos = a + b + 1 ;

		// a 尽可能的放前面，二分那个b带a和a带b的边界

		while (l <= r) {

			int mid = (l + r) >> 1 ;

			if (check(mid)) r = mid - 1, pos = mid ;

			else l = mid + 1 ;

		}

		rep(i, c, min(pos, d)) putchar((i % (x + 1)) ? 'A' : 'B') ;

		rep(i, max(c, pos + 1), d) putchar((a + b - i + 1) % (x + 1) ? 'B' : 'A') ;

		enter ;

	}

	return 0 ;

}



/*

写代码时请注意：

	1.ll？数组大小，边界？数据范围？

	2.精度？

	3.特判？

	4.至少做一些

思考提醒：

	1.最大值最小->二分？

	2.可以贪心么？不行dp可以么

	3.可以优化么

	4.维护区间用什么数据结构？

	5.统计方案是用dp？模了么？

	6.逆向思维？

*/






// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int T,a,b,l,r;

int solve(int l,int r){int s1=(l-1)/(r+1)+1,s2=(r-1)/(l+1)+1;if(s1<s2)s1=s2;return s1?s1:1;}

int main()

{

	scanf("%d",&T);

	while(T--)

	{

		scanf("%d%d%d%d",&a,&b,&l,&r);

		int as=solve(a,b);

		int lb=0,rb=1e9,as1=0;

		while(lb<=rb)

		{

			int mid=(lb+rb)>>1,fg=1;

			if(1ll*as*mid>a||mid>b)fg=0;

			if(fg&&solve(a-as*mid,b-mid+1)>as)fg=0;

			if(fg)as1=mid,lb=mid+1;

			else rb=mid-1;

		}

		int tp=as1*(as+1);

		if(l<=tp)for(int i=l;i<=r&&i<=tp;i++)printf("%c",i%(as+1)?'A':'B');

		a-=as*as1,b-=as1;

		l-=tp,r-=tp;if(l<1)l=1;

		lb=0,rb=as,as1=0;

		while(lb<=rb)

		{

			int mid=(lb+rb)>>1,fg=1;

			if(mid>a)fg=0;

			if(fg&&solve(a-mid,b)>as)fg=0;

			if(fg)as1=mid,lb=mid+1;

			else rb=mid-1;

		}

		if(l<=as1)for(int i=l;i<=r&&i<=as1;i++)printf("A");

		a-=as1;l-=as1,r-=as1;if(l<1)l=1;

		lb=0,rb=as,as1=0;

		while(lb<=rb)

		{

			int mid=(lb+rb)>>1,fg=1;

			if(mid>b)fg=0;

			if(fg&&solve(a,b-mid)>as)fg=0;

			if(fg)as1=mid,rb=mid-1;

			else lb=mid+1;

		}

		if(l<=as1)for(int i=l;i<=r&&i<=as1;i++)printf("B");

		b-=as1;l-=as1,r-=as1;if(l<1)l=1;

		int las=b-a*as;

		for(int i=l;i<=las&&i<=r;i++)printf("B");

		r-=las;l-=las;if(l<1)l=1;

		for(int i=l;i<=r;i++)printf("%c",i%(as+1)==1?'A':'B');

		printf("\n");

	}

}//

// Fastest known solution for this problem: