#include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; int main(){ ll f0,f1,N; cin >> f0 >> f1 >> N; if(N == 0){ cout << f0 << endl; return 0;} if(N == 1){ cout << f1 << endl; return 0;} vector f(1000,0); f[0] = f0; f[1] = f1; map mp; for(int i = 2;i <= N;i++){ if(mp.count(P(f[i-1],f[i-2]))){ N %= (i - mp[P(f[i-1],f[i-2])]); } f[i] = f[i-1] ^ f[i-2]; mp[P(f[i-1],f[i-2])] = i; } cout << f[N] << endl; return 0; }