import java.util.*; public class Run { public static void main (String arg[]) { Scanner scan = new Scanner(System.in); long F0 = scan.nextInt(); long F1 = scan.nextInt(); long N = scan.nextInt(); if (F0 < 0||F1 < 0||N > Math.pow(10d, 18)) System.exit(1); if (N==0) { System.out.println(F0); System.exit(0); } else { long tmp; for (int i = 0; i < N - 1; i++) { tmp = F1; F1 = F0 ^ F1; F0 = tmp; } System.out.println(F1); } } }