def solve(): f0, f1, N = map(int, input().split()) f = [f0, f1, f0 ^ f1] print(f[N % 3]) if __name__ == '__main__': solve()