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 if t%2 == 0: t_s[0] += 1 else: t_s[1] += 1 else: a += deme if t%2 == 0: a_s[0] += 1 else: a_s[1] += 1 print(min(t_s),min(a_s))