import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); long zero = koko.nextLong(); long one = koko.nextLong(); long n = koko.nextLong(); if(n%3==0){ System.out.println(zero); }else if(n%3==1){ System.out.println(one); }else{ String tz = Long.toBinaryString(zero); String to = Long.toBinaryString(one); int min = Math.min(tz.length(),to.length()); int max = Math.max(tz.length(),to.length()); char[] ans = new char[max]; if(tz.length()>to.length()){ for(int i=0; i