#include<bits/stdc++.h>
using namespace std;
int n;
struct Node{
    int no;
    double ps;
}a[105];
bool cmp(Node a,Node b){
    return a.ps>b.ps;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].no;
        int c[5]; 
        for(int j=0;j<=4;j++) cin>>c[j];
        sort(c,c+5);
        a[i].ps=(c[1]+c[2]+c[3])*1.0/3;
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=3;i++) {
        printf("%d %.3lf\n",a[i].no,a[i].ps);
    }
 
}
 
/**************************************************************
	Problem: 1315
	User: chenlingxuan
	Language: C++
	Result: Accepted
	Time:9 ms
	Memory:2080 kb
****************************************************************/