program c;
var
a:array[1..5,1..3] of integer;
i,j,x,max,min:integer;
begin
max:=0;
min:=70000;
for i:=1 to 5 do
for j:=1 to 3 do
readln(a[i,j]);
for i:=1 to 5 do
for j:=1 to 3 do begin
if a[i,j]>max then max:=a[i,j];
if a[i,j]
end;
writeln(max,' ',min);
end.