#include using namespace std; typedef long long ll; typedef pair P; #define mod 1000000007 #define inf 1000000000 #define all(x) (x).begin(), (x).end() #define pb push_back #define popcount(x) __builtin_popcountll(x) const long double PI = acos(-1); ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;} ll lcm(ll a,ll b){return a / gcd(a,b) * b;} int main(){ ll a, b, x, n; cin >> a >> b >> x >> n; ll m = pow(2, 32); ll prex = x, xi; vector ans1(2,0), ans2(2,0); for(ll i = 0; i < n; i++){ xi = (a * prex + b) % m; ll deme = xi % 6 + 1; if(deme % 2 == 0) ans1[0]++; else ans1[1]++; prex = xi; //cout << xi << endl; xi = (a * prex + b) % m; deme = xi % 6 + 1; if(deme % 2 == 0) ans2[0]++; else ans2[1]++; prex = xi; //cout << xi << endl; } cout << min(ans1[0], ans1[1]) << " "; cout << min(ans2[0], ans2[1]) << endl; return 0; }