import java.util.Scanner; public class Main64 { public static void main(String[] args) { Main64 p = new Main64(); } public Main64() { Scanner sc = new Scanner(System.in); long f0 = sc.nextLong(); long f1 = sc.nextLong(); long n = sc.nextLong(); solve(f0, f1, n); } public void solve(long f0, long f1, long n) { long res = 0; if(n%3==0) res = f0; else if(n%3==1) res = f1; else res = f0 ^ f1; System.out.println(res); } }