const xor = (a, b) => { let x = a, y = b if (x.length < y.length) { x = b y = a } let u = '' if (x.length != y.length) { let d = x.length - y.length u = x.substr(0, d) x = x.substr(d) } let xl = x.split('') let yl = y.split('') let r = xl.map((e, i) => e ^ yl[i]).join('') return u + r } const plus = (a, b) => { let r = [], u = 0 let x = a.concat().reverse(), y = b.concat().reverse() if (x.length < y.length) { let t = x x = y y = t } x.forEach((e,i) => { let k = e + u + (i < y.length ? y[i] : 0) u = Math.floor(k / 100000000) k %= 100000000 r.unshift(k) }) if (u != 0) r.unshift(u) return r } const minus = (a, b) => { let r = [], u = 0 let x = a.concat().reverse(), y = b.concat().reverse() if (x.length < y.length) { let t = x x = y y = t } if (x.length == y.lenght) { for (let c = length - 1; c <= 0 ; c--) { if (x[c] > y[c]) break else if (x[c] < y[c]) { let t = x x = y y = t break } } } x.forEach((e,i) => { let k = e - u - (i < y.length ? y[i] : 0) if (k >= 0) u = 0 else { u = 1 k += 100000000 } r.unshift(k) }) let d = 0 for (let c = 0; c < r.length; c++) { if (r[c] != 0) break d++ } for (; d > 0; d--) r.shift() return r } const binaryToDecimal = (a) => { let r = [0], p = [1] let b = a.split('').reverse() b.forEach((e) => { if (e != 0) r = plus(r, p) p = plus(p, p) }) return r } const decimalToBinary = (a) => { let t = a.split('').reverse() let x = [] t.forEach((e,i) => { let k = Math.floor(i / 8) x[k] = e + (x[k] === void 0 ? '' : x[k]) }) x.reverse() let b = [1] let bl = [] while (true) { bl.push(b) if (ge(b, x)) break b = plus(b,b) } let r = '' for (let c = bl.length-2; c >= 0; c--) { if (ge(x, bl[c])) { x = minus(x, bl[c]) r += '1' } else r += 0 } return r } const ge = (a, b) => { if (a.length > b.length) return true if (a.length < b.length) return false for (let c = 0; c < a.length; c++) { if (a[c] < b[c]) return false if (a[c] > b[c]) return true } return true } let i = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ') let c = i[2] % 3 let o = '' if (c == 0) o = i[0] else if (c == 1) o = i[1] else { if (i[0] > 10000000000000000 || i[1] > 10000000000000000) { let aa = decimalToBinary(i[0]) let bb = decimalToBinary(i[1]) let cc = xor(aa, bb) let rr = binaryToDecimal(cc) rr.forEach((e,i) => { o += ('00000000' + e).slice(-8) if (i == 0) o = parseInt(o, 10) + '' }) } else o = i[0] ^ i[1] } console.log(o)