import numpy as np a, b, x0, n = map(np.uint32, input().split()) x = x0 stones = [[0, 0], [0, 0]] now = [0, 0] for i in range(2 * n): turn = i % 2 x = a * x + b dice = x % 6 + 1 now[turn] += dice now[turn] %= 2 stones[turn][now[turn]] += 1 print(*list(map(min, stones)))