There are various food chains in any ecosystem, hawk, mouse and corn to name one. Mice feed on corn, hawks eat mice and life goes on. Given the relations between the species one can easily create food chains. One can also determine whether a chain is a cyclic one with caterpillars, plants, fungi and bacteria, as an example of cyclic chain. Caterpillars feed on plants, plants use organic substances produced by bacteria and fungi by decomposition of dead bodies of organisms such as caterpillars. These constitute a 3-member cyclic food chain. Your task is to find 3-member cyclic food chains. Input Unlimited number of tests. Each test consists of: number of observer species (n), consecutive n lines containing coincidence matrix describing food relations between species. There is ‘0’ in the (i,k)-th element when i-th species does not eat k-th species and respectively ‘1’ when it does so. Output Outputted cyclic chains, followed by word ‘total:’ and then number of cyclic chains. The chain consists of three species separated by spaces, for example ‘1 2 4’ means that 1 eats 2, which eats 4, and1isafoodfor4. Withsucharulethechain‘1 2 4’isidenticalwith‘4 1 2’and‘2 4 1’butnot with ‘4 2 1’ (inverted sequence of prey and predator). You should not print all identical chain (only that one with species sorted with ascend or descend order). Chains should be sorted. This means that the chains ‘1 2 4’, ‘1 2 3’ and ‘3 2 1’ should be printed in the following order: 123 124 321 Output a blank line after each test case. Assumptions: number of species in one test belongs to a range [3, 100]. Sample Input 3 010 001 100 3 001 100 010 3 011 101 110
2/2 4 0111 1011 1101 1110 Sample Output 123 total:1 321 total:1 123 321 total:2 123 124 134 234 321 421 431 432 total:8