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