import java.util.Scanner; class N064{ public static void main(String args[]){ Scanner s = new Scanner(System.in); long f0 = s.nextLong(); long f1 = s.nextLong(); long n = s.nextLong(); long f = 0; for(long i = 0; i < n -1; i++){ f = f0 ^ f1; f0 = f1; f1 = f; } if(n == 0){ System.out.println(f0); }else if(n == 1){ System.out.println(f1); }else{ System.out.println(f); } } }