import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] inputs = reader.readLine().split(" "); long f0 = Long.parseLong(inputs[0]); long f1 = Long.parseLong(inputs[1]); long N = Long.parseLong(inputs[2]); long f2 = f1 ^ f0; long[] fs = new long[3]; fs[0] = f0; fs[1] = f1; fs[2] = f2; for (long i = 3; i <= N; i++) { fs[0] = fs[2] ^ fs[1]; fs[1] = fs[2]; fs[2] = fs[0]; } if(N < 3) { System.out.println(fs[(int) N]); } else { System.out.println(fs[0]); } } }