Problem A
Balls and Needles

Joana Vasconcelos is a Portuguese artist who uses everyday objects in her creations, like electric irons or plastic cutlery. She is an inspiration to Ana, who wants to make ceiling hanging sculptures with straight knitting needles and balls of wool. For safety reasons, there will be a ball at each end of each needle. Knitting needles vary in colour, length and thickness (to allow intersections of needles).

Sculptures are to be exhibited in room corners, which
provide a 3D Cartesian coordinate system, with many lamps on
the ceiling. Sculpture designs are made with the coordinates of
the centres of the balls of wool in which knitting needles are
stuck. That is, each needle
Ana dislikes closed chains. A
true closed chain is a sequence of
But her dislike of closed chains is so extreme that the
shadow of the sculpture on the floor has to be free of “floor
closed chains”. Given any needle
-
, for every (the needle shadows are all distinct); -
Consider the sculpture depicted in the figure, which has the following four knitting needles:
This structure is not free of closed chains because,
although there is no true closed chain, the sequence of needles
Task
Write a program that, given the knitting needles of a sculpture, determines whether there is a true or a floor closed chain in the sculpture.
Input
The first line of the input has one integer,
Constraints
|
|
|
|
|
Number of knitting needles |
|
|
|
|
|
Coordinates of each triple |
Output
The output has two lines, each one with a string. The string in the first line is: True closed chains, if there is some true closed chain in the sculpture; No true closed chains, otherwise. The string in the second line is: Floor closed chains, if there is some floor closed chain in the sculpture; No floor closed chains, otherwise.
Sample Input 1 | Sample Output 1 |
---|---|
4 12 12 8 10 5 11 12 12 8 4 14 21 12 12 8 12 20 8 4 14 21 10 5 21 |
No true closed chains Floor closed chains |
Sample Input 2 | Sample Output 2 |
---|---|
4 1 1 1 2 2 2 2 2 2 1 5 5 9 4 4 9 4 2 9 4 4 9 9 4 |
No true closed chains No floor closed chains |
Sample Input 3 | Sample Output 3 |
---|---|
3 50 50 50 100 100 100 100 100 100 50 50 90 50 50 90 50 50 50 |
True closed chains No floor closed chains |
Sample Input 4 | Sample Output 4 |
---|---|
3 1 1 5 1 3 7 1 3 7 4 4 5 4 4 5 1 1 5 |
True closed chains Floor closed chains |