def main(): a, b, x0, N = map(int, input().split()) mod = 2**32 - 1 def linear_random(x: int) -> int: return (a * x + b) & mod takahashi = [0, 0, 0] aoki = [0, 0, 0] x = x0 for idx in range(N): x = linear_random(x) takahashi[2] += x % 6 + 1 match takahashi[2] % 2: case 0: takahashi[1] += 1 case 1: takahashi[0] += 1 x = linear_random(x) aoki[2] += x % 6 + 1 match aoki[2] % 2: case 0: aoki[1] += 1 case 1: aoki[0] += 1 print(min(takahashi[:2]), min(aoki[:2])) if __name__ == "__main__": main()