# -*- coding: utf-8 -*- """ No.64 XORフィボナッチ数列 https://yukicoder.me/problems/no/64 """ import sys from sys import stdin input = stdin.readline def main(args): F0, F1, N = map(int, input().split()) fibo = [F0, F1, F0^F1] if N <= 2: print(fibo[N]) else: print(fibo[(N+1)%2]) if __name__ == '__main__': main(sys.argv[1:])