{
    ACM ICPC 2003-2004 NEERC

    Problem:    Hypertransmission
    Author:     Nikolay Ignatiev
    Solution:   Dmitry Shtukenberg 
                (N^4 solution; should not pass testing)
}

program h_ds_n4;

var N: integer;
    x,y,z,p: array [1..1000] of longint;

    tmp_r, curr_r, max_r, old_r: longint;
    tmp_d, tmp_total, curr_d, max_d, old_d: integer;

    i,j,k,l: integer;

function dist( i,j: integer ): longint;
begin
  dist := (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) + (z[i]-z[j])*(z[i]-z[j]);
end;

begin
  read( N );
  for i := 1 to N do read( x[i],y[i],z[i],p[i] );

  max_r := 0;
  max_d := 0;
  old_r := 0;
  for i := 1 to N do
    for j := 1 to N do begin
      curr_r := 2000*2000;
      for k := 1 to N do
        for l := 1 to N do begin
          tmp_r := dist(k,l);
          if (tmp_r > old_r) and (tmp_r < curr_r) then curr_r := tmp_r;
        end;

      curr_d := 0;
      for k := 1 to N do begin
        tmp_d := 0;
        tmp_total := 0;
        for l := 1 to N do 
          if (dist(k,l) < curr_r+1e-8) then begin
            if p[k] <> p[l] then inc(tmp_d);
            inc(tmp_total);
          end;
        if tmp_d*2 > tmp_total then inc(curr_d);
      end;

      old_r := curr_r;
      if max_d < curr_d then begin max_r := curr_r; max_d := curr_d; end;
    end;

  writeln( max_d );
  writeln( sqrt(max_r):12:4 );
end.
