#include <bits/stdc++.h>
using namespace std;
#define int long long
struct node {
int c,m,e,i;
int a;
}a[100010];
bool cmp(int a,int b)
{
return a > b;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("main.in","r",stdin);
freopen("main.out","w",stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for(int i = 0;i < n;i++)
{
cin >> a[i].c >> a[i].m >> a[i].e;
i = a[i].i;
a[i].a = a[i].c + a[i].m + a[i].e;
}
sort(a,a+n,cmp);
for(int i = 0;i < n;i++)
{
cout << a[i].i << " " << a[i].a << endl;
}
return 0;
}