Do the segments intersect - 2#6346

Do the segments intersect - 2

1 second
64 megabytes
Medium

Given four points , , , and , determine if the line segments and share at least one common point.

The program should handle all scenarios, including cases where the segments overlap or when A = B or C = D, which means one or both segments reduce to a single point.

Input

Read the input from standard input. The first line contains an integer (1 \leq N \leq 5), representing the number of segment pairs in the test. This is followed by groups of two lines each. The first line of each group provides the coordinates of segment in the format A_x A_y B_x B_y. The second line of each group provides the coordinates of segment in the format C_x C_y D_x D_y. All coordinates are integers and do not exceed one million in absolute value.

Output

For each group, output YES on a separate line if the segments intersect, or NO if they do not.

Examples

Example 1

Loading
Loading