a,b,x,N=map(int,input().split()) M=[x] for i in range(2): M.append((M[-1]*a+b)%2) if M[1]==M[2]: print(0) else: print(N//2,N//2)