This page is still under construction.

Parts of this page are still being built. What you see may change.

Blocking the View

Time limit2sMemory limit512 MB

Summary
For each test, decide whether some point of segment a moved along direction v hits segment b, treating the segments as non-intersecting.
Level

Medium7 of 10

Topics
Geometry, Math, Implementation, Binary search
Solved
No attempts yet

Problem

Anton is developing a 2D graphics engine for video games. It has to reach the market. To display objects correctly, he needs to determine whether one object blocks the view to another object when the player looks in a particular direction.

For the prototype, Anton treats objects as non-intersecting segments on the plane. Segment aa blocks the view to segment bb in the direction of vector v⃗\vec{v} if there are points AA on aa and BB on bb such that the vectors AB→\overrightarrow{AB} and v⃗\vec{v} are co-directed. In other words, there is a point on aa that, if it starts moving along the direction of v⃗\vec{v}, would hit segment bb.

Anton is busy looking for investors, so he asks you to implement this part of the graphics engine.

Input

The first line of input contains an integer nn, the number of tests that follow (1≤n≤50 0001 \le n \le 50\,000).

Each of the following nn lines contains 10 integers: ax1ax_1, ay1ay_1, ax2ax_2, ay2ay_2, bx1bx_1, by1by_1, bx2bx_2, by2by_2, vxvx, vyvy. These are the coordinates of the endpoints of the first segment, the coordinates of the endpoints of the second segment, and the coordinates of the view direction vector. The absolute value of every coordinate is at most 10610^6. Each segment has positive length, and the direction vector v⃗\vec{v} is non-zero.

Output

For each test, print "Yes" if the first segment blocks the view to the second segment in the given direction, otherwise print "No".

Examples1

  1. Example 1

    Input
    2
    0 2 1 1 2 2 3 1 1 1
    0 2 1 1 2 2 3 1 -1 -1
    
    Expected output
    Yes
    No