{$q-,r-}
{$apptype console}
const
    max_n = 1000;

type
    pair = record
        d: int64;
        p1, p2: longint;
    end;

var
    d: array [1..max_n * max_n] of pair;

procedure qsort(l, r: longint);
var
    i, j: longint;
    x: int64;
    t: pair;
begin
    x := d[l + random(r - l + 1)].d;
    i := l;
    j := r;
    while i <= j do begin
        while (d[i].d < x) do inc(i);
        while (d[j].d > x) do dec(j);
        if i <= j then begin
            t := d[i]; d[i] := d[j]; d[j] := t;
            inc(i);
            dec(j);
        end;
    end;
    if l < j then qsort(l, j);
    if i < r then qsort(i, r);
end;

var
    i, j, n: longint;
    x, y, z: array [1..max_n] of int64;
    p, a: array [1..max_n] of longint;
    c, p1, p2: longint;
    q: int64;    
    s, ms: longint;
    mr: int64;
begin
    read(n);

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

    c := 0;
    for i := 1 to n do begin
        for j := i to n do begin
            inc(c);
            d[c].d :=
                (x[i] - x[j]) * (x[i] - x[j]) +
                (y[i] - y[j]) * (y[i] - y[j]) + sqr(z[i] - z[j]);
            d[c].p1 := i;
            d[c].p2 := j;
        end;
    end;
    qsort(1, c);

    fillchar(z, sizeof(z), 0);
    i := 1;
    ms := 0; mr := 0;
    s := 0;
    while i <= c do begin
        q := d[i].d;
        while (i <= c) and (d[i].d <= q) do begin
            p1 := d[i].p1;
            p2 := d[i].p2;
            if p[p1] = p[p2] then begin
                if p1 = p2 then begin
                    inc(a[p1]);
                    if a[p1] = 0 then dec(s);
                end else begin
                    inc(a[p1]);
                    inc(a[p2]);
                    if a[p1] = 0 then dec(s);
                    if a[p2] = 0 then dec(s);
                end;
            end else begin
                dec(a[p1]);
                dec(a[p2]);
                if a[p1] = -1 then inc(s);
                if a[p2] = -1 then inc(s);
            end;
            inc(i);
        end;
        if (ms < s) then begin
            ms := s;
            mr := q;
        end;
    end;

    writeln(ms);
    writeln(sqrt(mr * 1.0):0:6);

    {
    ms := 0;
    for i := 1 to n do begin
        s := 0;
        for j := 1 to n do begin
            if ((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) <= mr) then begin
                if (p[i] = p[j]) then inc(s) else dec(s);
            end;
        end;
        if s < 0 then inc(ms);
    end;
    writeln(ms);
    }
    close(input);
    close(output);

end.