const MaxN=1000;
      MaxC=10000;

var a, p, b, e:array [1..MaxN*(MaxN+1) shr 1] of integer;


procedure qsort (l, r:integer);
var i, j, x, y:integer;
begin
  if l>=r then exit;
  i:=l; j:=r; x:=p[(l+r) shr 1];
  repeat
    while a[p[i]]<a[x] do inc (i);
    while a[x]<a[p[j]] do dec (j);
    if i<=j then begin
      y:=p[i]; p[i]:=p[j]; p[j]:=y;
      inc (i); dec (j)
    end;
  until i>j;
  qsort (l, j);
  qsort (i, r);
end;


var x, y, z, d, np, nm:array [1..MaxN] of integer;
    i, j, ac, n, maxd, maxr, bb, ee, dest:integer;

begin
  read (n); for i:=1 to n do read (x[i], y[i], z[i], d[i]);
  ac:=0;
  for i:=1 to n do
    for j:=i+1 to n do begin
      inc (ac); a[ac]:=sqr (x[i]-x[j])+sqr (y[i]-y[j])+sqr (z[i]-z[j]);
      p[ac]:=ac; b[ac]:=i; e[ac]:=j;
    end;
  qsort (1, ac); maxd:=0; maxr:=0; dest:=0;
  a[ac+1]:=maxint; p[ac+1]:=ac+1;
  for i:=1 to n do np[i]:=1;
  for i:=1 to ac do begin
    bb:=b[p[i]]; ee:=e[p[i]];
    if d[bb]=d[ee] then begin 
      inc (np[bb]); if np[bb]=nm[bb] then dec (dest);
      inc (np[ee]); if np[ee]=nm[ee] then dec (dest);
    end else begin
      if np[bb]=nm[bb] then inc (dest); inc (nm[bb]);
      if np[ee]=nm[ee] then inc (dest); inc (nm[ee]);
    end;
    if (a[p[i]]<a[p[i+1]]) and (dest>maxd) then begin
      maxd:=dest;
      maxr:=a[p[i]];
    end;
  end;
  writeln (maxd);
  writeln (sqrt (maxr):0:10);
end.