#include using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(false); long long int a, b, x, n; cin >> a >> b >> x >> n; long long int x0 = a * x + b; x0 %= (1LL << 32); x0 %= 6; x0 += 1; if (x0 % 2 != 1) { cout << n / 2 << ' ' << 0 << '\n'; } else { cout << 0 << ' ' << n / 2 << '\n'; } return 0; }