#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <map>
#include <queue>
#include <cstring>
#include <set>
#include <stack>
using namespace std;
typedef long long int ll;

int min_k(ll a,ll b){
	int left=0,right=1e9;
	while(right-left>1){
		ll mid=(left+right)/2;
		if((a+1)*mid>=b&&(b+1)*mid>=a){
			right=mid;
		}else{
			left=mid;
		}
	}
	return right;
}

int cul(int a,int b,int k){
	int left=0,right=1e9;
	while(right-left>1){
		int mid=(left+right)/2;
		int aa=a-mid;
		int bb=b-max(0,(mid-1)/k);
		if(bb<=(ll)(aa+1)*k){
			left=mid;
		}else{
			right=mid;
		}
	}
	return left+max(0,(left-1)/k);
}

void query(int a,int b,int l,int r){
	int k=min_k(a,b);
	int right=cul(a,b,k);
	for(int i=l;i<=r;i++){
		if(i<=right){
			if(i%(k+1)==0){
				printf("B");
			}else{
				printf("A");
			}
		}else{
			int j=(a+b)-i+1;
			if(j%(k+1)==0){
				printf("A");
			}else{
				printf("B");
			}
		}
	}
	printf("\n");
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int q; cin >> q;
	while(q--){
		int a,b,c,d; cin >> a >> b >> c >> d;
		query(a,b,c,d);
	}
	return 0;
}
