#include<iostream> #include<string> using namespace std; struct s{ int id; int yw; int sx; int yy; int score; }a[310]; int n; int main() { cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].yw>>a[i].sx>>a[i].yy; a[i].id=i; a[i].score=a[i].yw+a[i].sx+a[i].yy; } for(int i=1;i<n;i++){ for(int j=1;j<=n-i;j++){ if(a[j].score<a[j+1].score){ s tmp; swap(a[j],a[j+1]); } else if(a[j].score==a[j+1].score&&a[j].yw<a[j+1].yw){ swap(a[j],a[j+1]); } else if(a[j].score==a[j+1].score&&a[j].yw&&a[j].id>a[j+1].id){ swap(a[j],a[j+1]); } } } for(int i=1;i<=5;i++){ cout<<a[i].id<<" "<<a[i].score<<endl; } return 0; }