2015华中科技大学ACM校赛初赛

From: 2015-05-09 13:00:00 To: 2015-05-09 18:00:00 Now: 2017-09-22 06:51:13 Status: Public

D - Hooked Triangle

Time Limit: 1s Memory Limit: 128MB

Submissions: 138 Solved: 18
Description

Given two triangles in 3D space, you are asked to tell if they are hooked together. They are called hooked together if you can’t separate them without breaking any of them.

Input

The first line contains the number of test cases. Each case have two lines: A1x A1y A1z B1x B1y B1z C1x C1y C1z A2x A2y A2z B2x B2y B2z C2x C2y C2z Indicating the coordinates of each triangle(A1B1C1 and A2B2C2). All numbers in the input file are integers in the range [0, 500]. The sides of the two triangles have no intersections.

Output

Output “YES” if they are hooked together or “NO” otherwise.

Sample Input
2
0 0 0 1 0 0 0 1 0
0 0 2 1 0 2 0 1 2
1 1 1 4 1 1 1 4 1
0 0 0 0 0 2 2 2 1
Sample Output
NO
YES
Hint
Source