def highest(dx, dy, xlo, xhi, ylo, yhi):
    """Return highest y reached with initial dx, dy velocity.

    Return -1 if probe doesn't hit target area"""
    x = y = maxy = 0    # initial probe coordinates and highest height
    hit = False         # I assume probe doesn't start within target area

    # stop moving probe when it hits target or moves past it
    while not hit and (x <= xhi and ylo <= y):
        x += dx
        y += dy
        if dx > 0: dx -= 1          # drag reduces dx; once dx = 0 it stays 0
        dy -= 1                     # gravity decreases dy
        hit = xlo <= x <= xhi and ylo <= y <= yhi
        maxy = max(maxy, y)
    return maxy if hit else -1