import scala.math._ object Main { def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) val f0, f1, n = sc.nextLong val m = (n % 3).toInt val ans = Array(f0, f1, f0 ^ f1)(m) println(ans) } }