F0, F1, N = map(int, input().split())
mod = N % 3
if mod == 0:
    print(F0)
elif mod == 1:
    print(F1)
else:
    print(F0 ^ F1)