#include<bits/stdc++.h>
using namespace std;
struct  wsl {
    int hs;
    float cj;   
}a[200];
bool cmp(wsl x,wsl y){
	if(x.cj>y.cj)return true;
	else return false;
}
int main(){
    int n,x,s,mn,mx;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].hs;
        s=0,mn=INT_MAX,mx=INT_MIN;
        for(int j=1;j<=5;j++){
            cin>>x;
            if(x<mn) mn=x;
            if(x>mx) mx=x;
            s=s+x;
        }
        a[i].cj=(s-mn-mx)*1.0/3;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=3;i++){
		printf("%d %.3f\n",a[i].hs,a[i].cj);
	}
    return 0;
}



















































/**************************************************************
	Problem: 1315
	User: wangsenlin
	Language: C++
	Result: Accepted
	Time:9 ms
	Memory:2080 kb
****************************************************************/