#define _USE_MATH_DEFINES #include //cin, cout #include //vector #include //sort,min,max,count #include //string,getline, to_string #include //fixed #include //setprecision #include //swap, pair #include //abs(int) #include //sqrt,ceil,M_PI, pow, sin #include //stringstream, getline #include //gcd, accumlate #include //deque #include //randam_device #include //numeric_limits using namespace std; constexpr long long int D_MOD = 1000000007; int main() { long long int a, b, x, N; cin >> a >> b >> x >> N; long long int m = pow(2, 32); unsigned int teban = 0; vector P(2); vector> A(2, vector(2)); for (int i = 0; i < N; i++) { for (int j = 0; j < 2; j++) { x = (a * x + b) % m; P[teban] += (x % 6) + 1; if (P[teban] % 2 == 1) { A[teban][0]++; } else { A[teban][1]++; } teban = 1 - teban; } teban = 1 - teban; } cout << min(A[0][0], A[0][1]) << " " << min(A[1][0], A[1][1]) << endl; return 0; }