#include <bits/stdc++.h>   using namespace std;   long long x, y, n;   long long arr[6];   int main() {     ios_base::sync_with_stdio(0);     cin >> x >> y >> n;     int pos = (n - 1) % 6;     arr[0] = (x + 1000000007) % 1000000007;     arr[1] = (y + 1000000007) % 1000000007;     arr[2] = (y - x + 1000000007 + 1000000007) % 1000000007;     arr[3] = (-x + 1000000007) % 1000000007;     arr[4] = (-y + 1000000007) % 1000000007;     arr[5] = (x - y + 1000000007 + 1000000007) % 1000000007;     cout << arr[pos] << endl;     return 0;   }   