//* Problem  : H. Hypertransmition
//* Contest  : NEERC-2003
//* Type     : Solution
//* Date     : 2008.08.01
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

typedef pair <int,int> PIII;
typedef vector <int> VI;
typedef vector <vector<int> > VVI;
typedef vector <pair<int,int> > VPII;
typedef vector <vector<pair<int,int> > > VVPII;

#define int64 long long
#define PI (2.0 * acos(0.0))
#define MP make_pair
#define PB push_back
#define SZ(a) (int)a.size()
#define FOR(i, n) for (int i = 0; i < (int)n; i++)
#define FORSZ(i, a) FOR(i, SZ(a))
#define FORE(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(a); i >= int(b); i--)
#define INF 1000000000
#define INFL 1000000000000000000LL
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()

inline int si(){int tt; scanf("%d", &tt); return tt;}

struct planet{
	int x, y, z, f;
}a[1024], b[1024];

int n, res, res_d;

int kk;

inline int sq(int x){return x * x;}

struct pos{
	int k1, k2, d;
}aa[1204 * 1024];  int na;

int cmp_f(const void *aa, const void *bb)
{
	return ((pos*)aa)->d - ((pos*)bb)->d;
}

void solve()
{
	FOR(i, n)
		FORE(j, i + 1, n - 1)
		{
			int dx = a[i].x - a[j].x; dx *= dx;
			int dy = a[i].y - a[j].y; dy *= dy;
			int dz = a[i].z - a[j].z; dz *= dz;
			int d = dx + dy + dz;
			aa[na].k1 = i;
			aa[na].k2 = j;
			aa[na].d = d;
			na++;
		}
	qsort(aa, na, sizeof(aa[0]), cmp_f);
	int cnt[1024][2];
	FOR(i, n)
	{
		cnt[i][a[i].f] = 1;
		cnt[i][1-a[i].f] = 0;
	}
	int t = 0;
	res = 0;
	int i = 0;
	while (i < na)
	{
		int j = i;
		while (i < na && aa[i].d == aa[j].d)
		{
			int k1 = aa[i].k1;
			int k2 = aa[i].k2, f1, f2;
			f1 = cnt[k1][a[k1].f] >= cnt[k1][1-a[k1].f];
			cnt[k1][a[k2].f]++;
			f2 = cnt[k1][a[k1].f] >= cnt[k1][1-a[k1].f];
			if (f1 != f2)
			{
				if (f1 > f2) t++;
				else t--;
			}
			f1 = cnt[k2][a[k2].f] >= cnt[k2][1-a[k2].f];
			cnt[k2][a[k1].f]++;
			f2 = cnt[k2][a[k2].f] >= cnt[k2][1-a[k2].f];
			if (f1 != f2)
			{
				if (f1 > f2) t++;
				else t--;
			}
			i++;
		}
		if (t > res)
		{
			res = t;
			res_d = aa[j].d;
		}
	}
}

void result()
{
	printf("%d\n%lf\n", res, sqrt(1.0*res_d));
}

int main()
{
#ifdef _DEBUG
	freopen("1064", "r", stdin);
#endif
	n = si();
	FOR(i, n)
	{
		a[i].x = si();
		a[i].y = si();
		a[i].z = si();
		a[i].f = si();
		b[i] = a[i];
	}
	solve();
	result();
	return 0;
}

