#include using namespace std; int main() { long F[3], C; cin >> F[0] >> F[1] >> C; F[2] = F[0] ^ F[1]; cout << F[C % 3] << endl; }