import Control.Applicative import Data.List import Data.Bits import Data.Array mex :: [Int] -> Int mex list = mex_sub 0 $ sort list where mex_sub n [] = n mex_sub n (x:xs) | n == x = mex_sub (n+1) xs | otherwise = n nextGrundy :: Array Int Int -> Int -> [Int] nextGrundy gr n = [foldl xor 0 [gr ! (i`div`2) | i<-[n,n+1]]] ++ (if n<3 then [] else [foldl xor 0 [gr ! (i`div`3) | i<-[n..n+2]]]) main = do l <- (read::String->Int) <$> getLine let gr = array (1,l) $ (1,0):[(i,(mex $ nextGrundy gr i))|i<-[2..l]] putStrLn $ if gr!l /= 0 then "A" else "B"