404980: GYM101726 C Ekaterinburg Pyramids

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Ekaterinburg Pyramidstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Pyramids are frequent structures in ancient civilizations all around the world. The most famous ones, in Egypt, were built over 2000 years before Christ. Other famous pyramids are found in Mexico and Central America, connected to the Mayan and Aztec civilizations.

Little know, however, are the pyramids built in the Ural Mountains, near the city of Ekaterinburg. Such pyramids are from the beginning of the Cristian era, and it is believed that it was built by the Mongols, that invaded Europe through the Ural Mountains from Asia. Differently from the other pyramids, they had a triangular base. Therefore, these pyramids had 4 triangular faces, and since they were held by pillars, no face had to be aligned to the ground.

This was very important, since the pyramid's faces were painted with figures of ancient gods, mythological figures, planets and so on. This way, in some point in the city, a citizen could see one or more faces of the pyramid. This was important in the local religion, and finding a house whose side could see the best faces of the pyramid was greatly valued in that time.

Your task is, given the position of the vertex of the pyramid, and the position of a citizen, determine which faces the citizen can see, considering there's no obstacle between the observer and the pyramid. We consider a point X sees a face if the line segment connecting X to any point Y in the face does not intersect any other point in the pyramid.

Input

In the first line an integer T, the number of test cases.

Each test case has 5 lines, each with 3 integers. The lines represent the points A, B, C, D and X, respectively, where X is the position of the citizen and the remaining points are the vertex of the pyramid.

Limits

  • 1 ≤ T ≤ 103
  • All points have coordinates with absolute value not exceeding 100.
  • The points A, B, C and D are not coplanar.
  • All points are distinct.
  • The point X is not in the interior nor in any face of the pyramid.
Output

for each instance, print a line with 4 characters. The first must be Y if the citizen can see the face of the pyramid opposed to the vertex A, or N otherwise. The second, third and fourth character must be printed analogously for B, C and D, respectively.

ExampleInput
3
0 0 0
1 0 0
0 1 0
0 0 1
1 1 1
0 0 0
1 0 0
0 1 0
0 0 1
-1 -1 -1
0 0 0
1 0 0
0 1 0
0 0 1
1 1 0
Output
YNNN
NYYY
YNNN

Source/Category

加入题单

上一题 下一题 算法标签: