import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

-- connPart lfs start size == sublist of a1 ++ a2 ++ ... ++ an
-- from start with size size
-- for each ai, (li, fi) is given in lfs, where li is the size of
-- ai and fi start size  gives the sublist of ai from start with sie size.
-- Note that connPart [(length as, \x y -> drop x (take y as)) | as in ass] start size == drop start (take size (concat ass))
connPart :: [(Int, Int -> Int -> [a])] -> Int -> Int -> [a]
connPart lfs start size =
  let cumList = dropWhile (\(cum, (sz, _)) -> cum + sz <= start)
                   $ zip (scanl (+) 0 (map fst lfs)) lfs 
  in case cumList of
  []                      -> []
  (cs1, (s1, f1)) : clfs2 -> res1 ++ res2
    where
      off1 = start - cs1
      sz1 = min (s1 - off1) size
      res1 = f1 off1 sz1
      lfs2 = map snd clfs2
      clfs3 = takeWhile ((> 0) . fst)
                $ zip (scanl (-) (size - sz1) (map fst lfs2)) lfs2
      res2 = concatMap (\(remS, (sz, f)) -> f 0 (min sz remS)) clfs3

-- partCycle as start size is the sublist of (cycle as)
-- starting at start with size size
-- Note that partCycle as start size == take size (drop start (cycle as))
partCycle :: [a] -> Int -> Int -> [a]
partCycle as start size
  | bEndN < bStart = drop remS $ take remE $ as
  | otherwise = pre ++ body ++ post
  where
    len = length as
    endN = start + size
    remS = start `rem` len
    remE = endN `rem` len
    bStart = lCeil start
    bEndN  = lFloor endN
    lFloor i = len * (i `div` len)
    lCeil i  = lFloor (i + len - 1)
    pre = if remS == 0 then [] else drop remS as
    body = concat $ take ((bEndN - bStart) `div` len) $ repeat as
    post = take remE as

test0 :: Int -> Int -> (Int, Int -> Int -> [Int])
test0 a b = (b, test1 a)

test1 :: Int -> Int -> Int -> [Int]
test1 a x y = [(a + x) .. (a + x + y - 1)]

solve :: Int -> [[Int]] -> [String]
solve _ = map eSolve 

ecase c1 c2 valC valD =
  take (valD - valC + 1) $ cycle [d1, d2]
  where (d1,d2) = if valC `mod` 2 == 1 then (c1,c2) else (c2,c1)

eSolve :: [Int] -> String
eSolve [valA,valB,valC,valD] 
  | valA == valB || valA == valB + 1 = ecase 'A' 'B' valC valD
  |                 valB == valA + 1 = ecase 'B' 'A' valC valD
  | otherwise = connPart partsDef (valC - 1) (valD - valC + 1)
  where
    bLen = (long + ((short + 1) - 1)) `div` (short + 1)
      where long = max valA valB
            short = min valA valB
    pre  = (bLen * valA - valB) `div` ((bLen - 1) * (bLen + 1))
    post = (bLen * valB - valA) `div` ((bLen - 1) * (bLen + 1))
    midA = valA - (bLen * pre + post)
    midB = valB - (pre + bLen * post)
    chars len c = take len (repeat c)
    abPre = (chars bLen 'A') ++ "B"
    abMid = (chars midA 'A') ++ (chars midB 'B')
    abPost = "A" ++ (chars bLen 'B')
    partsDef = [((bLen + 1) * pre, partCycle abPre),
                (midA + midB, \start size -> take size (drop start abMid)),
                ((bLen + 1) * post, partCycle abPost)]

main :: IO ()
main = do
  conts <- B.getContents
  let [valQ] : qs = map bsReadInts (B.lines conts)
      answer = solve valQ qs
  putStr $ unlines $ answer
