import java.util.*; public class Run { public static void main (String arg[]) { Scanner scan = new Scanner(System.in); long F0 = scan.nextLong(); long F1 = scan.nextLong(); long N = scan.nextLong(); 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); } } }