import Data.Bits fact :: [Integer] -> Integer fact [f0, f1, n] | n == 0 = f0 | n == 1 = f1 | otherwise = f f1 f0 (n - 2) where f a b i | i == 0 = a `xor` b | otherwise = f (a `xor` b) a (i - 1) main = getLine >>= print . fact . map read . words