Program Bally;
var a:array[1..250] of string;
N,l,max,x,i,b,p:integer;
z,k:string;
begin
max:=0;
readln(N);
for i:=1 to N do readln(a[i]);
z:=a[1];
l:=Pos(' ',z); Delete(z,1,l);
l:=Pos(' ',z); Delete(z,1,l);
Val(copy(z,1,Pos(' ',z)-1),x,l); max:=max+x;
Delete(z,1,Pos(' ',z));
Val(copy(z,1,Pos(' ',z)-1),x,l); max:=max+x;
Delete(z,1,Pos(' ',z));
Val(z,x,l); max:=max+x;
for i:=2 to N do begin
z:=a[i];
b:=0;
l:=Pos(' ',z); Delete(z,1,l);
l:=Pos(' ',z); Delete(z,1,l);
Val(copy(z,1,Pos(' ',z)-1),x,l); b:=b+x;
Delete(z,1,Pos(' ',z));
Val(copy(z,1,Pos(' ',z)-1),x,l); b:=b+x;
Delete(z,1,Pos(' ',z));
Val(z,x,l); b:=b+x;
if b>max then max:=b;
end;
for i:=1 to N do begin
z:=a[i];
b:=0;
l:=Pos(' ',z);
p:=l;
Delete(z,1,l);
l:=Pos(' ',z); p:=p+l;
Delete(z,1,l);
Val(copy(z,1,Pos(' ',z)-1),x,l); b:=b+x;
Delete(z,1,Pos(' ',z));
Val(copy(z,1,Pos(' ',z)-1),x,l); b:=b+x;
Delete(z,1,Pos(' ',z));
Val(z,x,l); b:=b+x;
if b=max then begin
z:=a[i];
delete(z,p,length(z)-p+1);
writeln(z);
end;
end;
end. Наверное так!!