#include using namespace std; typedef long long ll; int main(){ ll x,y,z; cin>>x>>y>>z; ll q[3]={x,y,x^y}; cout << q[z%3] << endl; }