#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXRETLEN=1000;

int na,nb,ql,qr;

bool cank(int k) {
	int mna=(na+k-1)/k,mnb=(nb+k-1)/k;
	return nb>=mna-1&&na>=mnb-1;
}

int calck() {
	int l=0,r=max(na,nb);
	while(l+1<r) {
		int m=l+(r-l)/2;
		if(cank(m)) r=m; else l=m;
	}
	return r;
}

int calcblocks(int k) { // blocks of (a*k)b (except last b)
	int l=0,r=na/k+1;
	while(l+1<r) {
		int m=l+(r-l)/2;
		if(na-m*k>=(nb-(m-1)+k-1)/k-1) l=m; else r=m;
	}
	return l;
}

int idx,k; char last;
char ret[MAXRETLEN+1]; int nret;

int calcarem(int k) { // b(a*?)
	if(last=='-') {
		return max(0,na-max(0,(nb+k-1)/k-1));
	} else {
		if(nb==0||na==0) return 0;
		return max(0,na-max(0,(nb-1+k-1)/k-1));
	}
}

void process(int times,int a1,int b,int a2) {
	if(times==0) return;
	if(last=='a') assert(a1==0&&(b!=0||a2==0));
	if(last=='b') assert(a1!=0||b==0);
	assert(a1==0||a2==0||b!=0);
	assert(a1<=k&&b<=k&&a2<=k);
	//printf("process(%d, %da %db %da)\n",times,a1,b,a2);
	if(idx<ql) {
		int len=a1+b+a2;
		int cur=min(times,(ql-idx)/len);
		na-=(a1+a2)*cur,nb-=b*cur,idx+=len*cur,times-=cur;
	}
	while(times>0&&idx<=qr) {
		int x1=a1;
		if(idx<ql) {
			int cur=min(ql-idx,x1);
			na-=cur; idx+=cur; x1-=cur;
		}
		while(x1>0&&idx<=qr) { ret[nret++]='A'; --na,++idx,--x1; }
		na-=x1; idx+=x1; x1=0;
		int x2=b;
		if(idx<ql) {
			int cur=min(ql-idx,x2);
			nb-=cur; idx+=cur; x2-=cur;
		}
		while(x2>0&&idx<=qr) { ret[nret++]='B'; --nb,++idx,--x2; }
		nb-=x2; idx+=x2; x2=0;
		int x3=a2;
		if(idx<ql) {
			int cur=min(ql-idx,x3);
			na-=cur; idx+=cur; x3-=cur;
		}
		while(x3>0&&idx<=qr) { ret[nret++]='A'; --na,++idx,--x3; }
		na-=x3; idx+=x3; x3=0;
		--times;
	}
	na-=(a1+a2)*times,nb-=b*times,idx+=(a1+b+a2)*times,times=0;
	if(a2>0) last='a'; else if(b>0) last='b'; else if(a1>0) last='a';
}

void solve(bool print) {
	//printf("na=%d nb=%d ql=%d qr=%d\n",na,nb,ql,qr);
	idx=0; nret=0; last='-';
	k=calck();
	int nblocks=calcblocks(k);
	if(nblocks>0) process(nblocks-1,k,1,0),process(1,k,0,0);
	int arem=calcarem(k);
	if(arem>0) process(1,0,last=='a'?1:0,arem);
	//printf("k=%d nblocks=%d arem=%d [%d %d]\n",k,nblocks,arem,na,nb);
	assert(na==0&&nb==0||na==(nb+k-1)/k-1);
	if(nb%k!=0) process(1,0,nb%k,na==0?0:1);
	assert(na==0&&nb==0||nb%k==0&&na==nb/k-1);
	if(nb!=0) process(nb/k-1,0,k,1),process(1,0,k,0);
	assert(na==0&&nb==0);
	if(print) { ret[nret]='\0'; printf("%s\n",ret); }
}


void run() {
	scanf("%d%d%d%d",&na,&nb,&ql,&qr); --ql,--qr;
	solve(true);
}

int main() {
	int n; scanf("%d",&n); FORE(i,1,n) run();
	//FORE(i,1,1000) FORE(j,1,1000) { /*printf("i=%d j=%d\n",i,j);*/ na=i,nb=j,ql=rand()%(na+nb),qr=rand()%(na+nb); if(ql>qr) swap(ql,qr); solve(false); }
	return 0;
}


Measured memory_bytes: 384