import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); try { String[] box = buff.readLine().split(" "); int[] f = new int[2]; f[0] = Integer.parseInt(box[0]); f[1] = Integer.parseInt(box[1]); int n = Integer.parseInt(box[2]); if(n < 2){ System.out.println(f[n]); return; } int now = 1; while(now++ < n){ int w = f[0] ^ f[1]; f[0] = f[1]; f[1] = w; } System.out.println(f[1]); } catch (NumberFormatException e) { } catch (IOException e) { } } }