a, b, n = gets.split(" ").map(&:to_i) case n % 3 when 0 puts a when 1 puts b when 2 puts a ^ b end