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(" "); long[] f = new long[2]; f[0] = Long.parseLong(box[0]); f[1] = Long.parseLong(box[1]); int n = Integer.parseInt(box[2]); if (n < 2) { System.out.println(f[n]); return; } int now = 1; while (now++ < n) { long w = f[0]^ f[1]; f[0] = f[1]; f[1] = w; } System.out.println(f[1]); } catch (NumberFormatException e) { e.getStackTrace(); } catch (IOException e) { e.getStackTrace(); } } }