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; long Fn1 = F1; long Fn2 = F0; for(int i = 3;i <= N;i++) { Fn2 = Fn1; Fn1 = Fn; Fn = Fn1 ^ Fn2; } if(N == 0) { System.out.println(F0); }else if(N == 1) { System.out.println(F1); }else { System.out.println(Fn); } } }