Triangles
You got a very strange gift for your birthday: two triangles in the three-dimensional space. Each triangle consists of three infinitely thin segments, and each segment stays straight no matter how hard you press it. Now, you actually wanted to get just one triangle, so you try to move the triangles far apart from each other, possibly after rotating one or both of them, so that you can throw away one of them. Is it possible? Or are they tangled?
Input
The fist line contains the number of test cases t (1 ≤ t ≤ 1000). Each test case consists of two lines. The first line contains 9 integers x[1]
, y[1]
, z[1]
, x[2]
, y[2]
, z[2]
, x[3]
, y[3]
, z[3]
in the range [-1000, 1000] denoting the vertices of the first triangle. The second line contains another 9 integers x'[1]
, y'[1]
, z'[1]
, x'[2]
, y'[2]
, z'[2]
, x'[3]
, y'[3]
, z'[3]
in the range [-1000, 1000] denoting the vertices of the second triangle. Both triangles will be non-degenerate, which means that the corresponding triples of points will not be collinear. Moreover, it is guaranteed that no pair of segments from two different triangles intersects, and there is no common plane containing both triangles at once.
Output
For each test case, output one line containing YES if the triangles are tangled, and NO if it is possible to move them very far apart from each other.