import java.util.*; import java.util.stream.Stream; import java.time.*; import java.time.format.*; public class No64 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int f0 = sc.nextInt(); int f1 = sc.nextInt(); int n = sc.nextInt(); if(n%3 == 0) { System.out.println(f0); }else if(n%3 == 1) { System.out.println(f1); }else { System.out.println(f0 ^ f1); } } }