#include <bits/stdc++.h>
using namespace std;

const int INF = 1e+9;
double eps = 1e-10;

int main() {
	int n, f, f1 = -1, f2 = -1, a, a1 = -1, a2 = -1, t, x, y, x1, y1, x2, y2;
	bool t1 = false, t2 = false;
	int ans1_d = -1, ans2_d = -1, ans1_s = INF, ans2_s = INF;
	cin >> n;
	for(int i = 0; i < n; ++i){
		scanf("%d%d%d%d%d", &f, &a, &t, &x, &y);
		if(t == 0){
			if(t1){
				if(a1 != a){
					int d = pow(x - x1, 2.0) + pow(y - y1, 2.0);
					int s = f - f1;
					if(ans1_d < d){
						ans1_d = d;
						ans1_s = s;
					}
					else if(d == ans1_d){
						ans1_s = min(ans1_s, s);
					}
				}
			}
			f1 = f;
			a1 = a;
			x1 = x;
			y1 = y;
			t1 = true;
			t2 = false;
		}
		else{
			if(t2){
				if(a2 != a){
					int d = pow(x - x2, 2.0) + pow(y - y2, 2.0);
					int s = f - f2;
					if(ans2_d < d){
						ans2_d = d;
						ans2_s = s;
					}
					else if(ans2_d == d){
						ans2_s = min(ans2_s, s);
					}
				}
			}
			f2 = f;
			a2 = a;
			x2 = x;
			y2 = y; 
			t1 = false;
			t2 = true;
		}
	}
	if(ans1_d == -1)
		cout << "-1" << " " << "-1" << endl;
	else
		cout << fixed << sqrt(ans1_d) << " " << ans1_s / 60.0 << endl;
	if(ans2_d == -1)
		cout << "-1" << " " << "-1" << endl;
	else
		cout << fixed << sqrt(ans2_d) << " " << ans2_s / 60.0 << endl;
	return 0;
}