#include using namespace std; int main() { long long a, b, x0, N; cin >> a >> b >> x0 >> N; long long aeven = 0; long long aodd = 0; long long teven = 0; long long todd = 0; long long m = pow( 2, 32 ); long long x = x0; long long t = 0; long long aa = 0; for( int i = 0; i < N * 2; i++ ) { x = (a * x + b) % m; if( i % 2 ) { aa += x % 6 + 1; if( aa % 2 ) aodd++; else aeven++; } else { t += x % 6 + 1; if( t % 2 ) todd++; else teven++; } } cout << min( teven, todd ) << " " << min( aeven, aodd ) << endl; }