#include <cstdio>
#include <cstring>
#include <algorithm>
 
int a, b, c, d;
namespace solver_std {
  int len;
  bool check(int na) {
    int nb = std::max(0, (na - 1) / len);
    return b - nb <= 1ll * (a - na + 1) * len;
  }
  void main() {
    len = (std::max(a, b) - 1) / (std::min(a, b) + 1) + 1;
    int l = 1, r = a, na = 0;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (check(mid)) {
        na = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    int nb = std::max(0, (na - 1) / len);
    int last = (b - nb) - (a - na) * len;
    for (int i = c; i <= d; i++) {
      if (i <= na + nb) {
        putchar(i % (len + 1) == 0 ? 'B' : 'A');
      } else if (i <= na + nb + last) {
        putchar('B');
      } else {
        putchar((i - na - nb - last) % (len + 1) == 1 ? 'A' : 'B');
      }
    }
    putchar('\n');
  }
}
namespace solver1 {
  char ans[200];
  char letter_a = 'A', letter_b = 'B';
  int rep_time, rep_len;
  bool full;
  int l, x, y;
  char get_ans(int p) {
    if (p <= rep_len) {
      if (!full && p > rep_time * (l + 1)) {
        if (p == rep_len) return letter_b;
        else return letter_a;
      } else {
        if (p % (l + 1) == 0) return letter_b;
        else return letter_a;
      }
    } else if (p <= rep_len + 2 * y) {
      if ((p - rep_len) & 1) return letter_a;
      else return letter_b;
    } else {
      return letter_b;
    }
  }
  void main() {
    letter_a = 'A', letter_b = 'B';
    bool flag = 0;
    if (a == b) {
      for (int i = c; i <= d; i++) {
        if (i & 1) putchar('A');
        else putchar('B');
      }
      puts("");
      return;
    }
    if (abs(a - b) == 1) {
      for (int i = c; i <= d; i++) {
        if (i & 1) putchar(a > b ? 'A' : 'B');
        else putchar(a < b ? 'A' : 'B');
      }
      puts("");
      return;
    }
    if (a < b) {
      std::swap(a, b);
      std::swap(letter_a, letter_b);
      c = a + b + 1 - c;
      d = a + b + 1 - d;
      std::swap(c, d);
    }
    l = (a - 1) / b + 1;
    x = std::max(0, (a - b + l - 2) / (l - 1) + 1);
    y = std::max(0ll, (1ll * l * (b + 1) - a - 1ll * l * l - 1) / (l - 1) + 1);
    if (l * x + y == a) rep_time = x, rep_len = x * (l + 1), full = 1;
    else {
      rep_time = x - 1;
      rep_len = a - y + x;
      full = 0;
    }
    //printf("%d %d %d %d %d\n", l, x, y, rep_time, rep_len);
    for (int i = c; i <= d; i++) {
      ans[i - c] = get_ans(i);
    }
    int len = d - c + 1;
    if (flag) {
      std::reverse(ans, ans + len);
    }
    ans[len] = 0;
    printf("%s\n", ans);
 
 
    /*
    if (a > b) {
      //int l = (a - 1) / b + 1;
 
      
      int rep_time = std::min(b, a / l);
      int rep_len = rep_time * (l + 1);
      int rem_a = a - l * rep_time, rem_b = b - rep_time;
      if (d <= rep_len) {
        for (int i = c; i <= d; i++) {
          if (i % (l + 1) == 0) putchar('b');
          else putchar('a');
        }
      } else if (c > rep_len) {
        if (rem_b <= l) {
          for (int i = c; i <= d; i++) {
            if (i - rep_len <= rem_a) putchar('a');
            else putchar('b');
          }
        } else {
          int blocks = (rem_b - 1) / l + 1;
          int blocks_rep_time = std
          for (int i = c; i <= d; i++) {
 
          }
        }
      } else {
        for (int i = c; i <= rep_len; i++) {
          if (i % (l + 1) == 0) putchar('b');
          else putchar('a');
        }
        for (
      }
      
    }
    */
 
  }
}
int main() {
  int q;
  scanf("%d", &q);
  while(q--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    solver_std::main();
  }
}


Measured memory_bytes: 256