import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long F0 = scan.nextInt(); long F1 = scan.nextInt(); long N = scan.nextLong(); scan.close(); long ans = 0; if(N % 3 == 0) { ans = F0; }else if(N % 3 == 1) { ans = F1; }else { ans = F0 ^ F1; } System.out.println(ans); } }