let () =
  let q = Scanf.scanf "%d\n" (fun q -> q) in
  let abcds = Array.init q (fun _ -> Scanf.scanf "%d %d %d %d\n" (fun a b c d -> a, b, c, d)) in
  Array.iter (fun (a, b, c, d) ->
    match compare a b with
    | -1 ->
        for i = c to d do
          (a + b - i) mod ((b + a) / (a + 1) + 1) < (a + b) / (a + 1)
          |> (function true -> 'B' | false -> 'A')
          |> print_char
        done
    | 0 ->
        for i = c to d do
          i mod 2 = 1
          |> (function true -> 'A' | false -> 'B')
          |> print_char
        done
    | 1 ->
        for i = c to d do
          (i - 1) mod ((a + b) / (b + 1) + 1) < (a + b) / (b + 1)
          |> (function true -> 'A' | false -> 'B')
          |> print_char
        done) abcds