import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long f0 = sc.nextLong(); long f1 = sc.nextLong(); long f2 = f0 ^ f1; long ans = f0; long N = sc.nextLong(); if(N % 3 == 1) ans = f1; if(N % 3 == 2) ans = f2; System.out.println(ans); } }