#include using ll = long long; using ull = unsigned long long; using ld = long double; #define rep(i,a,b) for (int i = a; i < b; i++) #define irep(i,a,b) for (int i = a; i > b; i--) #define print(n) cout << n << endl #define rup(a,b) (a+b-1)/b using namespace std; int main(){ cout << fixed << setprecision(15); ll a,b,n; cin >> a >> b >> n; if (n == 0){ print(a); return 0; }else if (n == 1){ print(b); return 0; } //f0 f1 f0*f1 f0 f1 f0*f1 if (n%3 == 0) {print(a);} else if(n%3 == 1) {print(b);} else print(ll(a ^ b)); //system("pause"); return 0; }