def main(): a,b,x,N=map(int,input().split()) c=c0=c1=d=d0=d1=0 for i in range(N): x=a*x+b&0xFFFFFFFF;c+=(x&1)+1 x=a*x+b&0xFFFFFFFF;d+=(x&1)+1 if c&1>0: c1+=1 else: c0+=1 if d&1>0: d1+=1 else: d0+=1 print(min(c0,c1),min(d0,d1)) main()