class Calc0064 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @f0, @f1, @n = args.shift.map(&:to_i) end def run fs = [@f0, @f1, @f0 ^ @f1] fs[@n % 3] end end puts Calc0064.new(STDIN.readlines).run if __FILE__ == $0