import Control.Arrow ((&&&)) import Data.Bits (Bits, xor) import Data.List (group) -- | Generates the sequence of prime numbers. -- Based on . primes :: Integral a => [a] primes = map fromIntegral primes' where primes' = [2, 3, 5] ++ sieve2 5 7 (drop 2 primes') sieve2 m s (p : ps) = [n | n <- ns, gcd m n == 1] ++ sieve2 (m * p) (p * p) ps where ns = [x + y | x <- [s, s + 6 .. p * p - 2], y <- [0, 4]] -- | Factorizes the given integer using 'primes'. -- Based on . factorize :: Integral a => a -> [a] factorize 1 = [] factorize n = factorize' n primes where factorize' n ps@(p : pr) | p * p > n = [n] | m == 0 = p : factorize' d ps | otherwise = factorize' n pr where (d, m) = divMod n p frequency :: Ord a => [a] -> [(Int, a)] frequency = map (length &&& head) . group xor2 :: Bits a => [a] -> a xor2 (x : []) = x xor2 (x : xs) = xor x $ xor2 xs main :: IO () main = putStrLn . (\x -> if x == 0 then "Bob" else "Alice") . xor2 .map fst . frequency . factorize =<< readLn