a,b,x,n=map(int,input().split()) L=[x] for i in range(4): L.append((L[-1]*a)+b) y=0 z=0 if not(L[0]%2==0 and L[2]%2==0): y=N//2 if not(L[1]%2==0 and L[3]%2==0): z=N//2 print(y,z)