#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{

	bool operator<(const struct Info &arg) const{
			return flame > arg.flame;
	};
	double flame,x,y;
	int number,country;
};

struct Pass{
	bool operator<(const struct Pass &arg) const{
			if(dist != arg.dist){
				return dist < arg.dist;
			}else{
				return time > arg.time;
			}
	};
	void set(double arg_time,double arg_dist){
		time = arg_time;
		dist = arg_dist;
	}

	double time,dist;
};

int main(){

	double pre_flame,pre_x,pre_y;
	int pre_country,pre_number;

	priority_queue<Info> Q;
	priority_queue<Pass> P_A,P_B;

	int N;
	scanf("%d",&N);

	Info info;
	for(int i = 0; i < N; i++){
		scanf("%lf %d %d %lf %lf",&info.flame,&info.number,&info.country,&info.x,&info.y);
		Q.push(info);
	}

	pre_flame = Q.top().flame;
	pre_number = Q.top().number;
	pre_country = Q.top().country;
	pre_x = Q.top().x;
	pre_y = Q.top().y;

	Q.pop();

	while(!Q.empty()){

		if(pre_country == Q.top().country && pre_number != Q.top().number){
			Pass pass;
			pass.set((Q.top().flame-pre_flame)/60.0,sqrt((pre_x-Q.top().x)*(pre_x-Q.top().x)+(pre_y-Q.top().y)*(pre_y-Q.top().y)));

			if(pre_country == 0){
				P_A.push(pass);
			}else{
				P_B.push(pass);
			}
		}

		pre_flame = Q.top().flame;
		pre_number = Q.top().number;
		pre_country = Q.top().country;
		pre_x = Q.top().x;
		pre_y = Q.top().y;

		Q.pop();

	}

	if(P_A.empty())printf("-1 -1\n");
	else{
		printf("%.10lf %.10lf\n",P_A.top().dist,P_A.top().time);
	}

	if(P_B.empty())printf("-1 -1\n");
	else{
		printf("%.10lf %.10lf\n",P_B.top().dist,P_B.top().time);
	}


	return 0;
}