#include using namespace std; int main() { int a, b, x, n; cin >> a >> b >> x >> n; unsigned pos1 = 0, pos2 = 0, b1 = 0, w1 = 0, b2 = 0, w2 = 0; for(int i = 0; i < n; i++) { x = a * x + b; pos1 += x; if(pos1 & 1) b1++; else w1++; x = a * x + b; pos2 += x; if(pos2 & 1) b2++; else w2++; } cout << min(b1, w1) << " " << min(b2, w2) << endl; return 0; }