#include //using namespace std; typedef unsigned long long ul; typedef signed long long ll; int main(void) { std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed; ul x, y, n; std::cin >> x >> y >> n; if (n%3==0) std::cout << x << std::endl; else if (n%3==1) std::cout << y << std::endl; else std::cout << (x^y) << std::endl; return 0; }