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