function main(input) { let L = input.shift().split(" ").map(x=>Number(x)); let N = L[2]; L[2] = L[0]^L[1]; console.log(L[N%3]); } main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n"));