import Data.Bits main = getLine >>= print . bfib . map read . words bfib [f0,f1,n] = [f0, f1, xor f0 f1] !! (mod n 3)