#include<bits/stdc++.h>
using namespace std;
struct Node{
	int no;
	double ps;
}a[105];
	bool cmp(Node a,Node b){
		return a.ps>b.ps;
}
int main(){
	int n;
	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);
	} 
	
	return 0;
}

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