//MIPT Cryptozoology 17.2
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
    string s = FILENAME;
    //assert(!s.empty());
    freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
#else
    //freopen(FILENAME ".in", "r", stdin);
    //freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        //cerr << testNum << endl;
        solve(true);
        //cerr << testNum - 1 << endl;
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cout.flush();
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

void precalc() {
}

template<typename T>
inline T nxt() {
    T cur;
    cin >> cur;
    return cur;
}

#define int li
//const int mod = 1000000007;

int get_res(int a, int b) {
    int L = 0, R = a + b;
    while (L + 1 < R) {
        int d = (L + R) / 2;
        if ((b + 1) * d >= a) {
            R = d;
        } else {
            L = d;
        }
    }
    return R;
}

string stupid(int A, int B) {
    string now = string(A, 'A') + string(B, 'B');
    int best_d = 1000000;
    string best_string;
    do {
        int d = 0;
        for (int i = 0; i < now.size(); ) {
            int j = i;
            while (j < now.size() && now[j] == now[i]) ++j;
            d = max(d, j - i);
            i = j;
        }
        if (d < best_d) {
            best_string = now;
            best_d = d;
        }
    }
    while (next_permutation(all(now)));
    return best_string;
}

void solve(bool read) {
    int a, b, C, D;
    if (read) {
        cin >> a >> b >> C >> D;
    } else {
        a = rand() % 1000000000 + 1;
        b = rand() % 1000000000 + 1;
        C = (a + b) / 2;
        D = C + 100;
    }
    int A = a, B = b;

    if (a >= b) {
        int d = get_res(a, b);

        if (d == 1) {
            string ans;
            for (int i = C - 1; i < D; ++i) {
                if (i % 2 == 0) {
                    ans += 'A';
                } else {
                    ans += 'B';
                }
            }
            cout << ans << "\n";
            if (!read && ans != stupid(A, B)) {
                cout << "FOUND " << A << " " << B << endl;
                cout << "ans: " << ans << " stupid: " << stupid(A, B) << endl;
                exit(0);
            }
            return;
        }

        int diff = a * d - b;
        int pref_b = 0;
        int full_steps = std::min(diff / (d * d - 1), b);
        a -= full_steps * d;
        b -= full_steps;
        while (b > 0 && (a - d) * d > b - 1) {
            ++full_steps;
            a -= d;
            --b;
        }

        int first_steps = full_steps;

        //cout << A << " " << B << " " << d << " " << first_steps << " " << a << " " << b << endl;

        vector<int> as, bs;
        do {
            if (b == 0) {
                as.push_back(a);
                break;
            }
            int need_a = (b + d - 1) / d;
            assert(need_a <= a);
            int take = min(a - need_a + 1, d);
            as.push_back(take);
            a -= take;
            int min_b = min(max(b - a * d, 1LL), d);
            //cout << take << " " << min_b << endl;
            //assert(min_b > 0 && min_b <= d);
            bs.push_back(min_b);
            b -= min_b;
        } while (as.back() != 1 || bs.back() != d);

        int trivial_steps = b / d;
        a -= trivial_steps;
        b -= trivial_steps * d;

        auto get_symbol = [&](int pos) {
          if (pos < first_steps * (d + 1)) {
              if (pos % (d + 1) == d) {
                  return 'B';
              } else {
                  return 'A';
              }
          } else {
              pos -= first_steps * (d + 1);
              /*if (pos < a) return 'A';
              return 'B';*/
              for (int i = 0; i < as.size(); ++i) {
                  if (pos < as[i]) return 'A';
                  pos -= as[i];
                  if (i < bs.size()) {
                      if (pos < bs[i]) return 'B';
                      pos -= bs[i];
                  }
              };
              if (pos < trivial_steps * (d + 1)) {
                  return (pos % (d + 1) == 0) ? 'A' : 'B';
              }
              pos -= trivial_steps * (d + 1);
              if (pos < a) {
                  return 'A';
              }
              return 'B';
          }
        };

        string ans;
        for (int pos = C - 1; pos < D; ++pos) {
            ans += get_symbol(pos);
        }

        /*if (!read && ans != stupid(A, B)) {
            cout << "FOUND " << A << " " << B << endl;
            cout << "ans: " << ans << " stupid: " << stupid(A, B) << endl;
            exit(0);
        }*/

        cout << ans << endl;

    } else {
        int d = get_res(b, a);
        if (d == 1) {
            string ans;
            for (int i = C - 1; i < D; ++i) {
                if ((A + B - 1 - i) % 2 == 0) {
                    ans += 'B';
                } else {
                    ans += 'A';
                }
            }
            cout << ans << "\n";
            /*if (!read && ans != stupid(A, B)) {
                cout << "FOUND " << A << " " << B << endl;
                cout << "ans: " << ans << " stupid: " << stupid(A, B) << endl;
                exit(0);
            }*/
            return;
        }

        int diff = a * d - b;
        int pref_b = 0;
        int full_steps = 0;
        if (diff < 0) {
            full_steps = 0;
            pref_b = b - a * d;
            b -= pref_b;
        } else {
            full_steps = diff / (d * d - 1);
            a -= full_steps * d;
            b -= full_steps;
            while ((a - d) * d > b - 1) {
                ++full_steps;
                a -= d;
                --b;
            }
        }

        vector<int> as, bs;
        do {
            if (b == 0) {
                assert(a == 0);
                break;
            }
            int need_a = (b + d - 1) / d;
            assert(need_a <= a);
            int take = min(a - need_a + 1, d);
            as.push_back(take);
            a -= take;
            int min_b = min(max(b - a * d, 1LL), d);
            //cout << take << " " << min_b << endl;
            //assert(min_b > 0 && min_b <= d);
            bs.push_back(min_b);
            b -= min_b;
        } while (as.back() != 1 || bs.back() != d);

        int trivial_steps = b / d;
        a -= trivial_steps;
        b -= trivial_steps * d;

        //cout << A << " " << B << " " << d << " " << pref_b << " " << full_steps << " " << between << " " << trivial_steps << " " << a << " " << b << endl;

        auto get_symbol = [&](int pos) {
            if (pos < pref_b) {
                return 'B';
            }
            pos -= pref_b;
            if (pos < full_steps * (d + 1)) {
                int rem = pos % (d + 1);
                return rem < d ? 'A' : 'B';
            }
            pos -= full_steps * (d + 1);

            for (int i = 0; i < as.size(); ++i) {
                if (pos < as[i]) return 'A';
                pos -= as[i];
                if (pos < bs[i]) return 'B';
                pos -= bs[i];
            };
            if (pos < trivial_steps * (d + 1)) {
                return (pos % (d + 1) == 0) ? 'A' : 'B';
            }
            pos -= trivial_steps * (d + 1);
            if (pos < a) {
                return 'A';
            }
            return 'B';
        };

        string ans;
        for (int pos = C - 1; pos < D; ++pos) {
            ans += get_symbol(pos);
        }

        /*if (!read && ans != stupid(A, B)) {
            cout << "FOUND " << A << " " << B << endl;
            cout << "ans: " << ans << " stupid: " << stupid(A, B) << endl;
            exit(0);
        }*/

        cout << ans << endl;
    }

}

Measured memory_bytes: 384