import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); long[] f = new long[3]; f[0] = in.nextLong(); f[1] = in.nextLong(); f[2] = f[0] ^ f[1]; long n = in.nextLong(); System.out.println(f[(int)(n%3)]); in.close(); } }