题目描述
Read problem statements in [Russian], [Mandarin Chinese], [Bengali], and [Vietnamese] as well.
There are three distinct points - A, B, C in the X-Y plane. Initially, you are located at point A. You want to reach the point C satisfying the following conditions:
You have to go through point B.
You can move in any of the four axis-parallel directions (+X, -X, +Y, -Y direction). However, you can make at most one turn in the path from A to C.
Determine if it is possible to reach the destination C satisfying the above conditions.
NOTE:
One turn means $90 ^ \circ$ clockwise or anticlockwise rotation along the direction of movement. For example, if you are moving towards the +X direction, after one turn you can move either in the +Y direction or in the -Y direction. Changing the direction by $180 ^ \circ$ is not allowed.
------ Input Format ------
- The first line of input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains two space-separated integers X_{A}, Y_{A}, denoting the coordinates of the starting point A.
- The second line of each test case contains two space-separated integers X_{B}, Y_{B}, denoting the coordinates of the point B.
- The third line of each test case contains two space-separated integers X_{C}, Y_{C}, denoting the coordinates of the finishing point C.
------ Output Format ------
For each test case, print a single line containing one string - "YES"(without quotes) if it is possible to reach the finishing point satisfying the above conditions, otherwise print "NO"(without quotes).
------ Constraints ------
$1 ≤ T ≤ 2 \cdot 10^{5}$
$-10^{9} ≤ X_{A}, Y_{A}, X_{B}, Y_{B}, X_{C}, Y_{C} ≤ 10^{9}$
- Three points are pairwise distinct
----- Sample Input 1 ------
4
1 1
1 3
3 3
0 0
2 2
3 4
5 2
3 2
1 2
1 1
-1 1
10000 10000
----- Sample Output 1 ------
YES
NO
YES
NO
----- explanation 1 ------
- Test case $1$: You start moving in the $+Y$ direction from $A = (1, 1)$, after two-unit steps you reach the point $B = (1, 3)$. Then you make a clockwise turn at point $B$ and start moving towards the $+X$ direction. After two-unit steps, you reach the finishing point $C = (3, 3)$.
-
Test case $2$: There is no possible way to reach the finishing point $C$ satisfying the above conditions. You have to make at least two turns in the path.
-
Test case $3$: You start moving in the $-X$ direction from $A = (5, 2)$ . After 4 unit steps, you reach the finish point $C = (1, 2)$. In the path from $A$ to $C$, you go through the point $B = (3,2)$ and don't make any turn.
输入格式
见题面
输出格式
见题面