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