import sys def input(): return sys.stdin.readline().rstrip() def main(): F0, F1, N = map(int, input().split()) print([F0, F1, F0 ^ F1][N % 3]) if __name__ == '__main__': main()