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