a,b,x,N = map(int,input().split(" ")) m = 2**32 now1 = 0 now2 = 0 c=[0,0] d = [0,0] for i in range(N): x = ((a*x+b)%m)%6+1 if i %2 == 0: now1 += x c[now1%2] += 1 else: now2 += x c[now2%2] += 1 print(min(c),min(d))