#include<bits/stdc++.h>
using namespace std;
struct wsl{
    int hs;
    float fs;
}a[200];
bool cmp(wsl x,wsl y){
    if(x.fs>y.fs)return true;
    else return false;
}
int main(){
int n,x,s=0,mx=INT_MIN,mn=INT_MAX;
cin>>n;//输入编号 
for(int i=1;i<=n;i++){
    cin>>a[i].hs;//输入成绩 
    s=0,mx=INT_MIN;mn=INT_MAX;//清零 
    for(int j=1;j<=5;j++){
        cin>>x; 
        if(x>mx)mx=x;//求最大最小
        if(x<mn)mn=x;
        s=s+x;//求总分 
    }
    a[i].fs=(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].fs);//四舍五入 
}
    return 0;
}
 
/**************************************************************
	Problem: 1315
	User: laichenxu
	Language: C++
	Result: Accepted
	Time:8 ms
	Memory:2080 kb
****************************************************************/