f0, f1, n = map(int, input().split()) F = [f0, f1, f0^f1] print(F[n%3])