시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 128 MB117660.000%

문제

Chain & Co. specializes in producing infinitely strong chains. Because of their high quality products, they are quickly gaining market share. This leads to new challenges, some of which they could have never imagined before. Like, for example, automatic verification of link endurance with a computer program, which you are supposed to write.

The company produces links of equal size. Each link is an infinitely thin square frame in three dimensions (made of four infinitely thin segments).

During tests all links are axis-aligned1 and placed so that no two frames touch. To make a proper strength test, two sets of links A and B are forged so that every link of A is inseparable from every link of B (being inseparable means that they cannot be moved apart without breaking one of them).

You stumble upon some links (axis-aligned, pairwise disjoint). Are they in proper testing position? In other words, can they be divided into two non-empty sets A and B with the desired property?

1Axis-aligned means that all segments are parallel to either X, Y, or Z axis.

입력

The first line of input contains the number of test cases T. The descriptions of the test cases follow:

The description of each test case starts with an empty line. The next line contains an integer n, 1 ≤ n ≤ 106 – the number of links in the chain. Each of the next n lines contains 6 space separated integers xi, yi, zi, xi', yi', zi', all between -109 and 109 – the coordinates of two opposite corners of the i-th link.

출력

For each test case, print a single line containing the word YES if the set is in proper testing position, or NO otherwise.

예제 입력 1

3

2
0 0 0 0 10 10
-5 5 15 5 5 25

5
0 0 0 0 10 10
-5 5 6 5 5 16
-5 5 -6 5 5 4
-5 6 5 5 16 5
-5 -6 5 5 4 5

3
0 0 0 3 0 -3
1 -1 -1 1 2 -4
-1 -2 -2 2 1 -2

예제 출력 1

NO
YES
YES