import java.util.Scanner; class Yuki64 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int n = sc.nextInt(); int x = 0; if(n>=2){ x = fib(b,a,n); } else if(n==0){ x = a; } else if(n==1){ x = b; } System.out.println(x); } private static int fib(int b,int a,int n) { int c = b^a; n-=1; if(n==1) return c; return fib(c,b,n); } }