import java.util.Scanner; public class Yukicoder64 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long f0 = sc.nextLong(); long f1 = sc.nextLong(); long N = sc.nextLong(); long fn = 0; if (N == 0) fn = f0; else if (N == 1) fn = f1; else { for (long i = 2; i <= N; i++) { fn = f0 ^ f1; f0 = f1; f1 = fn; } } System.out.println(fn); } }