#include <iostream>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

int ga, gb;
int depth;

vector<pair<pair<int, int>, int>> get(long long a, long long b, int k)
{
    if (a <= k && b <= k) {
        vector<pair<pair<int, int>, int>> ret;
        ret.push_back(make_pair(make_pair(a, b), 1));
        return ret;
    }
    long long l = 1, r = a + b + 1;
    if (a > b) {
        if (b * k < a) {
            vector<pair<pair<int, int>, int>> ret;
            ret.push_back(make_pair(make_pair(k, 1), b));
            ret.push_back(make_pair(make_pair(a - b * k, 0), 1));
            return ret;
        }
        while(l + 1 < r) {
            long long mid = (l + r) / 2;
            long long la = a - mid * k, lb = b - mid;
            if (la < 0 || lb < 0 || la * k < lb || lb * k < la) {
                r = mid;
            } else {
                l = mid;
            }
        }
        long long la = a - l * k, lb = b - l;
        vector<pair<pair<int, int>, int>> ret = get(la, lb, k);
        ret.insert(ret.begin(), make_pair(make_pair(k, 1), l));
        return ret;
    } else {
        if (a * k < b) {
            vector<pair<pair<int, int>, int>> ret;
            ret.push_back(make_pair(make_pair(0, b - a * k), 1));
            ret.push_back(make_pair(make_pair(1, k), a));
            return ret;
        }
        while(l + 1 < r) {
            long long mid = (l + r) / 2;
            long long lb = b - mid * k, la = a - mid;
            if (la < 0 || lb < 0 || la * k < lb || lb * k < la) {
                r = mid;
            } else {
                l = mid;
            }
        }
        long long lb = b - l * k, la = a - l;
        vector<pair<pair<int, int>, int>> ret = get(la, lb, k);
        ret.push_back(make_pair(make_pair(1, k), l));
        return ret;
    }
}

void solve()
{
    int n;
    cin >> n;
    for( ; n--; ) {
        depth = 0;
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int len;
        if (a >= b) {
            len = (a - 1) / (b + 1) + 1;
        } else {
            len = (b - 1) / (a + 1) + 1;
        }
        //cout << len << endl;
        vector<pair<pair<int, int>, int>> vec = get(a, b, len);
        /*
        for(auto e: vec) {
            cout << '(' << e.first.first << ' ' << e.first.second << ' ' << e.second << ')' << endl;
        }
        */
        for(int i = c; i <= d; ++ i) {
            int x = i;
            for(int j = 0; j < vec.size(); ++ j) {
                int a = vec[j].first.first;
                int b = vec[j].first.second;
                int mul = vec[j].second;
                if (x <= (a + b) * mul) {
                    x %= a + b;
                    if (x == 0) x += a + b;
                    if (x <= a) putchar('A');
                    else putchar('B');
                    break;
                } else {
                    x -= (a + b) * mul;
                }
            }
        }
        puts("");
    }
}

int main()
{
    /*
    for(ga = 1000; ga >= 1; --ga) {
        for(gb = 1; gb <= 1000; ++ gb) {
            solve();
        }
    }
    */
    //ga = 1000; gb = 499;
    solve();
    return 0;
}


Measured memory_bytes: 384