Balls and Needles

Joana Vasconcelos is a Portuguese artist who uses everyday ob- jects in her creations, like electric irons or plastic cutlery. She is an inspiration to Ana, who wants to make ceiling hanging sculp- tures 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 pro- vide 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 N is represented by a set of two different triples: N = {(x, y, z), (x′, y′, z′)}. Ana dislikes closed chains. A true closed chain is a sequence of k distinct needles, N1, N2, . . . , Nk (for some k ≥ 3), such that: • N1 = {(x1, y1, z1), (x2, y2, z2)}, N2 = {(x2,y2,z2), (x3,y3,z3)}, ..., Nk = {(xk, yk, zk), (xk+1, yk+1, zk+1)}, and (xk+1, yk+1, zk+1) = (x1, y1, z1). 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 N = {(x, y, z), (x′, y′, z′)}, let N↓ = {(x, y), (x′, y′)} denote the shadow of needle N on the floor. For Ana (who is an artist), a floor closed chain is also a sequence of k distinct needles, N1,N2,...,Nk (for some k ≥ 3), such that: ↓↓ A = {(12, 12, 8), (10, 5, 11)}, B = {(12, 12, 8), (4, 14, 21)}, C = {(12, 12, 8), (12, 20, 8)}, D = {(4, 14, 21), (10, 5, 21)}. This structure is not free of closed chains because, although there is no true closed chain, the sequence of needles A, B, D is a floor closed chain. 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. • N ̸=N ,forevery1≤i<j≤k (thekneedleshadowsarealldistinct); ij ↓↓ • N1 = {(x1,y1), (x2,y2)}, N2 = {(x2,y2), (x3,y3)}, ..., ↓ Nk = {(xk, yk), (xk+1, yk+1)}, and (xk+1, yk+1) = (x1, y1). Consider the sculpture depicted in the figure, which has the following four knitting needles:

2/2 Input The input file contains several test cases, each of them as described below. The first line of the input has one integer, K, which is the number of knitting needles in the sculpture. Each of the following K lines contains six integers, x1, y1, z1, x2, y2, and z2, which indicate that {(x1, y1, z1), (x2, y2, z2)} is the set of triples of a needle. Any two distinct needles are represented by different sets of triples. Constraints 1 ≤ K ≤ 50 000 Number of knitting needles 1 ≤ xi, yi, zi < 1 000 Coordinates of each triple Output For each test case, the output must follow the description below. 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 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 3 50 50 50 100 100 100 100 100 100 50 50 90 50 50 90 50 50 50 4 111222 222155 944942 944994 3 115137 137445 445115 Sample Output No true closed chains Floor closed chains True closed chains No floor closed chains No true closed chains No floor closed chains True closed chains Floor closed chains