import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long F0 = sc.nextLong(), F1 = sc.nextLong(), N = sc.nextLong(); sc.close(); if (N % 3 == 0) System.out.print(F0); else if (N % 3 == 1) System.out.print(F1); else System.out.print(F0 ^ F1); } }