package me.yukicoder.lv1_5; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class No0064 { public static void main(String[] args) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { String[] str = br.readLine().split(" "); long f0 = Long.parseLong(str[0]); long f1 = Long.parseLong(str[1]); long n = Long.parseLong(str[2]); System.out.println(xor(f1, f0, n)); } catch (IOException e) { e.printStackTrace(); } } static long xor(long f1, long f0, long n) { if (n == 0) { return f0; } else if (n == 1) { return f1; } long fk1 = f1; long fk2 = f0; long fk = fk1 ^ fk2; for (long i = 0; i < n - 2; i++) { fk2 = fk1; fk1 = fk; fk = fk1 ^ fk2; } return fk; } }