{
    ACM ICPC 2003-2004 NEERC

    Problem:    Hypertransmission
    Author:     Nikolay Ignatiev
    Solution:   Andrew Stankevich
}

{$APPTYPE CONSOLE}
{ $DEFINE ALLOWMULTITEST}
{$O-,Q+,R+}

program hypertransmission;

type
    tevent = record
        d: longint;
        c1, c2: integer;
        db: integer;
    end;

const
    maxn = 1000;
    maxm = maxn * maxn div 2;
    minc = -10000;
    maxc = 10000;

var
    i, j, n, m: integer;
    count, best: integer;
    r: longint;
    x, y, z: array [1..maxn] of longint;
    p: array [1..maxn] of integer;
    b: array [1..maxn] of integer;
    e: array [1..maxm] of tevent;

    a, t: tevent;

procedure sort(l, r: integer);
var
    i, j: integer;
begin
    a := e[l + random(r - l + 1)];
    i := l;
    j := r;
    while i <= j do
    begin
        while e[i].d < a.d do inc(i);
        while e[j].d > a.d do dec(j);
        if i <= j then
        begin
            t := e[i]; e[i] := e[j]; e[j] := t;
            inc(i);
            dec(j);
        end;
    end;
    if i < r then sort(i, r);
    if l < j then sort(l, j);
end;

begin

    if eoln then runerror(239);
    read(n);
    if not eoln then runerror(239);
    readln;
    if (n < 1) or (n > maxn) then runerror(239);

    for i := 1 to n do
    begin
        if eoln then runerror(239);
        read(x[i]);
        if eoln then runerror(239);
        read(y[i]);
        if eoln then runerror(239);
        read(z[i]);
        if eoln then runerror(239);
        read(p[i]);
        if not eoln then runerror(239);
        readln;

        if (x[i] < minc) or (x[i] > maxc) then runerror(239);
        if (y[i] < minc) or (y[i] > maxc) then runerror(239);
        if (z[i] < minc) or (z[i] > maxc) then runerror(239);
        if (p[i] <> 0) and (p[i] <> 1) then runerror(239);
    end;
    {$IFNDEF ALLOWMULTITEST}
    if not eof then runerror(239);
    {$ENDIF}

    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);

    for i := 1 to n do
    begin
        b[i] := 1;
    end;

    m := 0;
    for i := 1 to n do
        for j := i + 1 to n do
        begin
            inc(m);
            e[m].d := 
                (x[i] - x[j]) * (x[i] - x[j]) + 
                (y[i] - y[j]) * (y[i] - y[j]) +
                (z[i] - z[j]) * (z[i] - z[j]);
            e[m].c1 := i;
            e[m].c2 := j;
            if p[i] = p[j] then
                e[m].db := 1
            else
                e[m].db := -1;
        end;

    randseed := 2003;

    sort(1, m);

    best := 0;
    count := 0;
    r := 0;

    i := 1;
    while i <= m do
    begin
        j := i;
        while (j <= m) and (e[j].d = e[i].d) do
        begin
            b[e[j].c1] := b[e[j].c1] + e[j].db;
            if (b[e[j].c1] = -1) and (e[j].db < 0) then
                inc(count);
            if (b[e[j].c1] = 0) and (e[j].db > 0) then
                dec(count);
            b[e[j].c2] := b[e[j].c2] + e[j].db;
            if (b[e[j].c2] = -1) and (e[j].db < 0) then
                inc(count);
            if (b[e[j].c2] = 0) and (e[j].db > 0) then
                dec(count);

            inc(j);
        end;

        if count > best then
        begin
            best := count;
            r := e[i].d;
        end;

        i := j;
    end;

    writeln(best);
    writeln(sqrt(1.0 * r) :0 :6);

    close(input);
    close(output);
end.