a, b, x, n = [int(w) for w in input().split()] m = 2 ** 32 p1 = [0, 0] p2 = [0, 0] pos1 = 0 pos2 = 0 is_turn_1 = True def turn(player, dice, pos): pos += dice % 6 + 1 player[pos % 2] += 1 for i in range(n): x = (a * x + b) % m if is_turn_1: turn(p1, x, pos1) else: turn(p2, x, pos2) print(min(p1), min(p2))