a,b,x,N = map(int,input().split()) m = 2**32 X = [x] for i in range(N): X.append(((a*X[i-1]+b)%m)%6+1) La = [0] Lt = [0] for i in range(1,N+1,2): La.append(La[-1] + X[i]) for i in range(2,N+1,2): Lt.append(Lt[-1] + X[i]) ab = 0 aw = -1 tb = 0 tw = -1 for i in La: if La[i] % 2 == 1: ab += 1 elif La[i] % 2 == 0: aw += 1 for i in Lt: if Lt[i] % 2 == 1: tb += 1 elif Lt[i] % 2 == 0: tw += 1 print(min(ab,aw),min(tb,tw))