a, b, x0, N = map(int, input().split()) pos = [0, 0] stone = [[0, 0], [0, 0]] x = x0 for i in range(2 * N): x = (a * x + b) % 4294967296 pos[i % 2] += (x % 6) + 1 stone[i % 2][pos[i % 2] % 2] += 1 print(min(stone[0]), min(stone[1]))