import strutils, sequtils, math proc tBin(i: int): string = var bf = i var w = "" while bf != 0: w = int(bf mod 2 != 0).repr & w bf = bf div 2 result = w proc xOR0(x0: string, y0: string): string = var x, y: string y = align(y0, max(x0.len, y0.len), '0') x = align(x0, max(x0.len, y0.len), '0') result = "" for i in 0 ..< x.len: if ($x[i]).parseInt + ($y[i]).parseInt == 1: result.add('1') else: result.add('0') proc rpr(s: string): int = for i, v in s: if $v == $1: result += 2 ^ (s.high - i) let ris = stdin.readLine.split.map(parseInt) let (f0, f1, n) = (ris[0], ris[1], ris[2]) let f2 = xOR0(f0.tBin, f1.tBin).rpr case n mod 3: of 0: echo f0 of 1: echo f1 of 2: echo f2 else: discard