//No.64 XORフィボナッチ数列 import java.util.*; import java.io.*; import static java.util.Arrays.*; import static java.lang.Math.*; public class No64 { static final Scanner sc = new Scanner(System.in); static final PrintWriter out = new PrintWriter(System.out,false); static void solve() { long[] f = new long[3]; f[0] = sc.nextLong(); f[1] = sc.nextLong(); long n = sc.nextLong(); f[2] = f[0]^f[1]; out.println(f[(int)(n%3)]); } public static void main(String[] args) { long start = System.currentTimeMillis(); solve(); out.flush(); long end = System.currentTimeMillis(); //trace(end-start + "ms"); sc.close(); } static void trace(Object... o) { System.out.println(deepToString(o));} }