from sys import stdin, stdout input = lambda: stdin.readline().rstrip() println = stdout.write def main(): F0, F1, N = map(int, input().split()) xor = (F0, F1, F0 ^ F1) print(xor[N%3]) main()