f0, f1, n = gets.split.map(&:to_i) ans = [f0, f1, f1 ^ f0] puts ans[n % 3]