CSES - Line Segment Intersection
  • Time limit: 1.00 s
  • Memory limit: 512 MB

There are two line segments: the first goes through the points (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2), and the second goes through the points (x3,y3)(x_3,y_3) and (x4,y4)(x_4,y_4).

Your task is to determine if the line segments intersect, i.e., they have at least one common point.

Input

The first input line has an integer tt: the number of tests.

After this, there are tt lines that describe the tests. Each line has eight integers x1x_1, y1y_1, x2x_2, y2y_2, x3x_3, y3y_3, x4x_4 and y4y_4.

Output

For each test, print "YES" if the line segments intersect and "NO" otherwise.

Constraints

  • 1t1051 \le t \le 10^5
  • 109x1,y1,x2,y2,x3,y3,x4,y4109-10^9 \le x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4 \le 10^9
  • (x1,y1)(x2,y2)(x_1,y_1) \neq (x_2,y_2)
  • (x3,y3)(x4,y4)(x_3,y_3) \neq (x_4,y_4)

Example

Input:

5
1 1 5 3 1 2 4 3
1 1 5 3 1 1 4 3
1 1 5 3 2 3 4 1
1 1 5 3 2 4 4 1
1 1 5 3 3 2 7 4

Output:

NO
YES
YES
YES
YES