#include using namespace std; typedef long long ll; int main() { ll f[3]; int n; cin >> f[0] >> f[1] >> n; f[2] = f[0] ^ f[1]; cout << f[n%3] << endl; return 0; }