a,b,x,N = map(int,input().split()) nowt = 0 nowa = 0 countt = 0 counta = 0 mod = 1 << 32 for i in range(N): x = (a * x + b) % mod nowt += x % 6 + 1 if nowt & 1: countt += 1 x = (a * x + b) % mod nowa += x % 6 + 1 if nowa & 1: counta += 1 t = min(countt,N - countt) a = min(counta,N - counta) print(t,a)