def walk_exit_step(walk):
    """
    Determines the step at which a walk exits the upper quarterplane.
    """
    x, y = 0, 0
    i = 0
    for step in walk:
        x += step.x
        y += step.y
        i += 1
        if x < 0 or y < 0:
            return i
    return i
