def shoot(vx: int, vy: int, right: int, bottom: int) -> tuple[int, int]:
    """Simulate a shot and get the last position that's not out of bounds.

    Args:
        vx: The horizontal speed.
        vy: The vertical speed.
        right: The right bound.
        bottom: The bottom bound.

    Returns:
        The (x, y) coordinates of the last position that's not out of bounds.
    """
    x = y = 0
    dvx = vx // abs(vx)
    while x + vx <= right and y + vy >= bottom:
        x += vx
        y += vy
        if vx != 0:
            vx -= dvx
        vy -= 1

    return x, y