def main(): a,b,x,N=map(int,input().split()) a,b,x=a&0xF,b&0xF,x&0xF c=c0=c1=d=d0=d1=0 for i in range(N): x=a*x+b&0xF;c+=(x&1)+1 x=a*x+b&0xF;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()