a, b, n = gets.split.map(&:to_i) f = [a, b, a ^ b] puts f[n % 3]