var i,j,k,l,max,n:longint;
a,b,c,d,ans:array[1..1000] of longint;
begin
read(n);
for i:=1 to n do
begin
read(b[i],c[i],d[i]);
a[i]:=i;
ans[i]:=b[i]+c[i]+d[i];
end;
for i:=1 to n do
for j:=i+1 to n do
begin
if ans[i]>ans[j] then
begin
l:=ans[i];
ans[i]:=ans[j];
ans[j]:=l;
l:=a[i];
a[i]:=a[j];
a[j]:=l;
end;
if (ans[i]=ans[j])and(b[i]=b[j]) then
begin
l:=ans[i];
ans[i]:=ans[j];
ans[j]:=l;
l:=a[i];
a[i]:=a[j];
a[j]:=l;
end;
if (ans[i]=ans[j])and(a[j]<a[i])and(b[i]=b[j]) then
begin
l:=ans[i];
ans[i]:=ans[j];
ans[j]:=l;
l:=a[i];
a[i]:=a[j];
a[j]:=l;
end;
end;
for j:=n downto 1 do
begin
inc(k);
if k=6 then break;
if (j<>1) then writeln(a[j],' ',ans[j]) else write(a[j],' ',ans[j]);
end;
end.
P1093