{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"MD","content":"A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monkey is clever enough, it shall be able to reach the banana by placing one block on the top another to build a tower and climb up to get its favorite food.\n\nThe researchers have \u003cI\u003en\u003c/I\u003e types of blocks, and an unlimited supply of blocks of each type. Each type-\u003cI\u003ei\u003c/I\u003e block was a rectangular solid with linear dimensions (\u003cI\u003ex\u003cSUB\u003ei\u003c/SUB\u003e, y\u003cSUB\u003ei\u003c/SUB\u003e, z\u003cSUB\u003ei\u003c/SUB\u003e\u003c/I\u003e). A block could be reoriented so that any two of its three dimensions determined the dimensions of the base and the other dimension was the height.\n\nThey want to make sure that the tallest tower possible by stacking blocks can reach the roof. The problem is that, in building a tower, one block could only be placed on top of another block as long as the two base dimensions of the upper block were both strictly smaller than the corresponding base dimensions of the lower block because there has to be some space for the monkey to step on. This meant, for example, that blocks oriented to have equal-sized bases couldn\u0027t be stacked.\n\nYour job is to write a program that determines the height of the tallest tower the monkey can build with a given set of blocks.\n\n### Input Specification\n\nThe input file will contain one or more test cases. The first line of each test case contains an integer \u003cI\u003en\u003c/I\u003e,\n\nrepresenting the number of different blocks in the following data set. The maximum value for \u003cI\u003en\u003c/I\u003e is 30.\n\nEach of the next \u003cI\u003en\u003c/I\u003e lines contains three integers representing the values \u003cI\u003ex\u003cSUB\u003ei\u003c/SUB\u003e\u003c/I\u003e, \u003cI\u003ey\u003cSUB\u003ei\u003c/SUB\u003e\u003c/I\u003e and \u003cI\u003ez\u003cSUB\u003ei\u003c/SUB\u003e\u003c/I\u003e.\n\nInput is terminated by a value of zero (0) for \u003cI\u003en\u003c/I\u003e.\n\n### Output Specification\n\nFor each test case, print one line containing the case number (they are numbered sequentially starting from 1) and the height of the tallest possible tower in the format \"Case \u003cI\u003ecase\u003c/I\u003e: maximum height \u003d \u003cI\u003eheight\u003c/I\u003e\"\n\n### Sample:\n\n\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\n1\n10 20 30\n2\n6 8 10\n5 5 5\n7\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n5 5 5\n6 6 6\n7 7 7\n5\n31 41 59\n26 53 58\n97 93 23\n84 62 64\n33 83 27\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\nCase 1: maximum height \u003d 40\nCase 2: maximum height \u003d 21\nCase 3: maximum height \u003d 28\nCase 4: maximum height \u003d 342\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n"}}]}