#include <iostream>#include <stdio.h>#include <string>#include <algorithm>using namespace std;struct node{ int x, y, z, h;};bool cmp(node a, node b){ return a.x*a.y < b.x*b.y;}void change(int &a, int &b, int &c){ int t; if(a>b) {t=a; a=b; b=t;} if(a>c) {t=a; a=c; c=t;} if(b>c) {t=b; b=c; c=t;}}int main(){ int n; int T =1; while(scanf("%d", &n)!=EOF && n) { node num[500]; //int dp[500]; //memset(dp, 0, sizeof(dp) ); int flag =0; for(int i=0; i<n; i++) { int a, b, c; scanf("%d%d%d", &a, &b, &c); change(a, b, c); num[flag].x = a; num[flag].y = b; num[flag++].z = c; num[flag].x = a; num[flag].y = c; num[flag++].z = b; num[flag].x = b; num[flag].y = c; num[flag++].z = a; } sort(num, num+flag, cmp); int all = 0; num[0].h = num[0].z; for(int i=0; i<flag; i++) { int max = 0; for(int j=0; j<i; j++) { if(num[j].x < num[i].x && num[j].y < num[i].y && max < num[j].h) max = num[j].h; } num[i].h = max + num[i].z; } for(int i=0; i<flag; i++) if(all < num[i].h) all = num[i].h; printf("Case %d: maximum height = %d\n",T++,all); } return 0;}