import Data.Bits import Data.Word main = getLine >>= print . solve . map read . words solve :: [Word64] -> Word64 solve [f0, f1, n] | n == 0 = f0 | n == 1 = f1 | otherwise = snd $ foldl (\(b2, b1) x -> (b1, xor b1 b2)) (f1, xor f0 f1) [3..n]