Intersection#3925

Intersection

5 seconds
256 megabytes
Hard

In three-dimensional space, you are given two rectangular parallelepipeds, and your task is to determine whether they intersect.

Input

The input begins with a single integer indicating the number of test cases. Each test case consists of two sets of four lines, each describing a parallelepiped. The first line of each set provides the coordinates of one vertex of the parallelepiped, denoted as , , (-10000 \le x, y, z \le 10000), separated by spaces. The following three lines describe three vectors (edges) v_1, v_2, v_3 that are adjacent to the given vertex.

Each vector V_i is represented as (x_i, y_i, z_i) with the constraint (-10000 \le x_i, y_i, z_i \le 10000).

Output

For each test case, output a single line: NO if the parallelepipeds do not intersect, and YES if they do intersect.

Examples

Example 1

Loading
Loading