def mod(n,m): return int(math.fmod(n,m)) import math t = 0 t_s = [0,0] a = 0 a_s = [0,0] a,b,x,N = map(int,input().split()) for i in range(N*2): x = mod(3*x+b,2**32) deme = x%6+1 if i%2 == 0: t += deme t_s[t%2] += 1 else: a += deme a_s[t%2] += 1 print(min(t_s),min(a_s))