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