mf0,mf1,n = gets.chomp.split(" ").map(&:to_i) f0 = mf0 f1 = mf1 a = 0 i = 0 p = 0 while(1 <= f0 or 1 <= f1) if((f0%2+f1%2) == 1) a += 2**i end f0 /= 2 f1 /= 2 i += 1 end if(n%3 == 0) puts mf0 elsif(n%3 == 1) puts mf1 else puts a end =begin 88 79 2 =end