#include"bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++) #define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--) #define all(a) (a.begin()),(a.end()) #define rall(a) (a.rbegin()),(a.rend()) #define fi first #define se second #define pb push_back #define eb emplace_back using ll = long long; using vll = vector; using vi = vector; using vvi = vector>; using P = pair; void Main(){ ll a, b, x, n; cin >> a >> b >> x >> n; const ll MOD = (1LL << 32); int now = 0; int tb = 0; int tw = 0; int ab = 0; int aw = 0; rep(i, n){ int eye = a * x + b; eye %= 6; eye++; now += eye; now %= 2; if(now % 2) tb++; else tw++; eye = a * x + b; eye %= 6; eye++; now += eye; now %= 2; if(now % 2) ab++; else aw++; } cout << min(tb, tw) << " " << min(ab, aw) << endl; return; } int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); Main(); return 0; }