#include <iostream> using namespace std; typedef long long LL; int main(int argc, char* argv[]) { LL F[3]; LL N; cin>>F[0]>>F[1]>>N; if (N==0){ cout<<F[0]<<endl; return 0; }else if (N==1){ cout<<F[1]<<endl; return 0; } F[2]=F[0]^F[1]; cout<<F[N%3]<<endl; return 0; }