/**
 *    author:  tourist
 *    created: 01.01.2018 23:47:18       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    long long a, b, from, to;
    cin >> a >> b >> from >> to;
    long long x = (a + b) / (min(a, b) + 1);
    long long low = 0, high = a;
    while (low < high) {
      long long mid = (low + high + 1) >> 1;
      long long remB = b - max(0LL, mid - 1) / x;
      long long remA = a - mid;
      if (remB <= (remA + 1) * x) {
        low = mid;
      } else {
        high = mid - 1;
      }
    }
    long long bound = low + max(0LL, low - 1) / x;
    for (long long pos = from; pos <= to; pos++) {
      char res;
      if (pos <= bound) {
        res = (pos % (x + 1) == 0 ? 'B' : 'A');
      } else {
        res = ((a + b - pos + 1) % (x + 1) == 0 ? 'A' : 'B');
      }
      cout << res;
    }
    cout << endl;
  }
  return 0;
}
