a, b, n = map(int, input().split()) i = 0 while i < n: a, b = b, a^b i += 1 print(a)