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