eolymp
bolt
Try our new interface for solving problems
Problems

Triangles

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 (1t1000). Each test case consists of two lines. The first line contains 9 integers x1, y1, z1, x2, y2, z2, x3, y3, z3 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.

Time limit 1 second
Memory limit 128 MiB
Input example #1
2
0 0 0 10 0 0 0 10 0
1 1 10 1 1 -10 10 10 0
0 0 0 10 0 0 0 10 0
11 0 0 0 11 0 11 11 1
Output example #1
YES
NO
Source German Collegiate Programming Contest 2013