f0, f1, n = [int(x) for x in input().split()] a = (f0, f1, f0 ^ f1) print(a[n % 3])