import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long F0 = sc.nextLong(); long F1 = sc.nextLong(); long F2 = F0^F1; Long C = sc.nextLong(); if(C%3==0){ System.out.println(F0); }else if(C%3==1){ System.out.println(F1); }else{ System.out.println(F2); } } }