import java.util.Scanner; class Yuki64 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long a = sc.nextLong(); long b = sc.nextLong(); long n = sc.nextLong(); long 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 long fib(long b,long a,long n) { long c = b^a; n-=1; if(n==1) return c; return fib(c,b,n); } }