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; if (N % 3 == 0) fn = f0; else if (N % 3 == 1) fn = f1; else fn = f0 ^ f1; System.out.println(fn); } }