import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); int zero = koko.nextInt(); int one = koko.nextInt(); int n = koko.nextInt(); if(n%3==0){ System.out.println(zero); }else if(n%3==1){ System.out.println(one); }else{ String tz = Integer.toBinaryString(zero); String to = Integer.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