#include using namespace std; using ll = long long; using Graph = vector>; #define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i) #define rep(i,n) REP(i,0,n) #define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i)) #define all(x) (x).begin(),(x).end() #define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w) constexpr int INF = 1000000001; constexpr ll mod = 1000000007; constexpr double PI = 3.1415926535897932; templateinline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } templateinline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } template T pow(T a, T b) { if (b == 0)return 1; if (b % 2) { T ret = pow(a, (b - 1) / 2); return ret * ret * a; } else { T ret = pow(a, b / 2); return ret * ret; } } int main() { init(); ll a, b, x, N; cin >> a >> b >> x >> N; ll m = pow(2LL, 32); vector>vec(2, { 0,0 }); ll tk = 0, ao = 0; rep(i, N){ x = (a * x + b) % m; if (i % 2 == 0) { tk = x % 6 + 1; if (tk % 2 == 0)vec[0].first++; else vec[0].second++; } else { ao = x % 6 + 1; if (ao % 2 == 0)vec[1].first++; else vec[1].second++; } } cout << min(vec[0].first, vec[0].second) << " " << min(vec[1].first, vec[1].second) << "\n"; return 0; }