#include using namespace std; int main(){ long long a,b,c;cin>>a>>b>>c; if(c%3 == 1){ cout << b << endl; }else if(c%3){ cout << (a^b) << endl; }else{ cout << a << endl; } }