#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(false); uint a, b, x, n; cin >> a >> b >> x >> n; vector pos(2, 0); vector ev(2, 0); vector od(2, 0); for(uint i = 0; i < n; i++){ x = a * x + b; uint y = 1 - x & 1; uint s = i & 1; pos[s] += y; if(pos[s] & 1){ od[s]++; }else{ ev[s]++; } } cout << min(ev[0], od[0]) << " " << min(ev[1], od[1]) << "\n"; }