{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eA 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.\u003cbr\u003e\u003cbr\u003eThe researchers have n types of blocks, and an unlimited supply of blocks of each type. Each type-i block was a rectangular solid with linear dimensions (xi, yi, zi). 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. \u003cbr\u003e\u003cbr\u003eThey 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. \u003cbr\u003e\u003cbr\u003eYour job is to write a program that determines the height of the tallest tower the monkey can build with a given set of blocks.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input file will contain one or more test cases. The first line of each test case contains an integer n,\u003cbr\u003erepresenting the number of different blocks in the following data set. The maximum value for n is 30.\u003cbr\u003eEach of the next n lines contains three integers representing the values xi, yi and zi.\u003cbr\u003eInput is terminated by a value of zero (0) for n.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For 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 case: maximum height \u003d height\".\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\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\u003e1\r\n10 20 30\r\n2\r\n6 8 10\r\n5 5 5\r\n7\r\n1 1 1\r\n2 2 2\r\n3 3 3\r\n4 4 4\r\n5 5 5\r\n6 6 6\r\n7 7 7\r\n5\r\n31 41 59\r\n26 53 58\r\n97 93 23\r\n84 62 64\r\n33 83 27\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: maximum height \u003d 40\r\nCase 2: maximum height \u003d 21\r\nCase 3: maximum height \u003d 28\r\nCase 4: maximum height \u003d 342\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}