{
    ACM ICPC 2003-2004 NEERC

    Problem:    Hypertransmission
    Author:     Nikolay Ignatiev
    Solution:   Maxim Babenko
}

{$APPTYPE CONSOLE}

const
    inFile = 'hyper.in';
    outFile = 'hyper.out';

    maxN = 1000;
    maxE = maxN * maxN div 2;
    maxC = 10000;

type
    real = extended;

    TEvent = record
        u, v : integer;
        key : integer;
    end;

var
    n : integer;
    x, y, z, p : array[1..maxN] of integer;

    ne : integer;
    e : array[1..maxE] of TEvent;
    slist : array[1..maxE] of integer;

    np, nm : array[1..maxN] of integer;

    ansD : integer;
    ansR : real;


procedure QSort;
var
    i : integer;

    procedure Sort(l, r: longint);
    var
        i, j, x, y : longint;

      begin
         i := l;
         j := r;
         x := slist[l + random(r - l)];
         repeat
            while e[slist[i]].key < e[x].key do
                inc(i);
            while e[x].key < e[slist[j]].key do
                dec(j);
            if i <= j then begin
                y := slist[i];
                slist[i] := slist[j];
                slist[j] := y;
                inc(i);
                dec(j);
            end;
        until i > j;

        if l < j then
            Sort(l, j);
        if i < r then
            Sort(i, r);
    end;

begin
    for i := 1 to ne do
        slist[i] := i;
    Sort(1, ne);
end;

procedure Solve;
var
    i, j : integer;
    u, v : integer;
    curD : integer;

begin
    ne := 0;
    for i := 1 to n do
        for j := i + 1 to n do begin
            inc(ne);
            e[ne].u := i;
            e[ne].v := j;
            e[ne].key :=
                (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;

    QSort;

    for i := 1 to n do begin
        np[i] := 1;
        nm[i] := 0;
    end;

    curD := 0;
    ansD := 0;
    ansR := 0.0;

    i := 1;
    while i <= ne do begin
        j := i;
        while (j <= ne) and (e[slist[i]].key = e[slist[j]].key) do begin
            u := e[slist[j]].u;
            v := e[slist[j]].v;

            if np[u] < nm[u] then
                dec(curD);
            if np[v] < nm[v] then
                dec(curD);

            if p[u] = p[v] then begin
                inc(np[u]);
                inc(np[v]);
            end else begin
                inc(nm[u]);
                inc(nm[v]);
            end;

            if np[u] < nm[u] then
                inc(curD);
            if np[v] < nm[v] then
                inc(curD);

            inc(j);
        end;

        if curD > ansD then begin
            ansD := curD;
            ansR := sqrt(1.0 * e[slist[i]].key);
        end;

        i := j;
    end;
end;

procedure ReadData;
var
    i, j : integer;

begin
    read(n);
    if (n < 1) or (n > maxN) then
        RunError(239);

    for i := 1 to n do begin
        read(x[i], y[i], z[i], p[i]);
        if (abs(x[i]) > maxC) or (abs(y[i]) > maxC) or (abs(z[i]) > maxC) then
            RunError(239);
        if (p[i] <> 0) and (p[i] <> 1) then
            RunError(239);
    end;

    for i := 1 to n do
        for j := i + 1 to n do
            if (x[i] = x[j]) and (y[i] = y[j]) and (z[i] = z[j]) then
                RunError(239);
end;

procedure WriteData;
begin
    writeln(ansD);
    writeln(ansR:0:4);
end;

begin
    ReadData;
    Solve;
    WriteData;
end.
