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