1305 - Hooked Triangle

Time Limit : 1 Second

Memory Limit : 128 MB

Submission: 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
© 2015 HUST ACMICPC TEAM. All Right Reserved.