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(); if(n % 3 == 0){ System.out.println(f0); }else if(n % 3 == 1){ System.out.println(f1); }else{ System.out.println(f0 ^ f1); } } }