class calc(): ''' self.a = 0 self.b = 0 self.x = 0 ''' def __init__(self, a, b, x): self.m = 2 ** 32 self.a = a self.b = b self.x = x def next(self): self.x = (self.a * self.x + self.b) % self.m #return (self.x % 6) + 1 return (self.x) + 1 a, b, x, N = map(int, input().strip().split(' ')) C = calc(a, b, x) T, A = 0,0 lst1 = [0,0] lst2 = [0,0] for i in range(N): T += C.next() lst1[T % 2] += 1 A += C.next() lst2[A % 2] += 1 print('{} {}'.format(min(lst1), min(lst2)))