Perhaps you have heard of the legend of the Tower of Babylon. Nowadays many details of this tale have been forgotten. So now, in line with the educational of the contest, we'll tell you the whole story:
The Babylonians had n types of blocks, and a unlimited supply of blocks of each type. Each type-i blocks is a rectangular solid with linear dimensions . A Block could is reoriented so, any two of it three dimensions determined the dimensions of the base and the other Di Mension was the height. They wanted to construct the tallest tower possible by stacking. The problem was then, in building a tower, one blocks could only is 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 to the lower block. This is meant, for example, which blocks oriented to have equal-sized the bases ' t be couldn.
Your job is to write a program that determines the height of the tallest tower the Babylonians can builds with a given set of blocks.
Input and Output
The input file would contain one or more test cases. The ' a ' of each test case contains a integer n, representing the number of different blocks in the follow ing data set. The maximum value for n is 30. Each of the next n lines contains three integers representing the values , and .
The Input is terminated by a value of zero (0) for N.
For each test case, print one line containing the case number (they are numbered sequentially starting from 1) and the HEI Ght of the tallest possible tower in the format case : Maximum height = height
Sample Input
1
2
6 8 ten 5
5 5 7 1
1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 + 6 7
5 to the
0 in which he was a
Sample Output
Case 1:maximum height = case
2:maximum height = case
3:maximum height = case
4:maximum height = 342