F0, F1, N = gets.split.map(&:to_i) ans = if N % 3 == 0 F0 elsif N % 3 == 1 F1 else F0 ^ F1 end puts(ans)