#include<bits/stdc++.h>
using namespace std;
int n,x,mn=INT_MAX,mx=INT_MIN,s;
struct fx{
	int bh;
	int cj;
}a[110];
bool cmp(fx b,fx c){
	return b.cj>c.cj;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].bh;
			s=0;
		mn=INT_MAX,mx=INT_MIN;
		for(int j=1;j<=5;j++){
			cin>>x;
			s=s+x;
			if(x>mx)mx=x;
			if(x<mn)mn=x;	
			
		}
		a[i].cj=(s-mn-mx)*1.0/3;	
	//cout<<a[i].bh<<" "<<s<<" "<<a[i].cj<<endl;
	}	
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=3;i++){
		printf("%d %.3f\n",a[i].bh,a[i].cj);
	}
	
	

	return 0;
}

/**************************************************************
	Problem: 1315
	User: wuzihang
	Language: C++
	Result: Wrong Answer
****************************************************************/