#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const ll INF=1000000000000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

ll dist(P x,P y){
	return (x.fr-y.fr)*(x.fr-y.fr) + (x.sc-y.sc)*(x.sc-y.sc);
}

int main(){
	ll n,f[102],a[102],t[102],x[102],y[102];
	cin >> n;
	rep(i,n){
		cin >> f[i] >> a[i] >> t[i] >> x[i] >> y[i];
	}
	
	ll rd_a = -1,rt_a = -1;
	ll rd_b = -1,rt_b = -1;
	rep1(i,n-1){
		if(a[i] != a[i-1] && t[i] == t[i-1]){
			ll d = dist(P(x[i],y[i]),P(x[i-1],y[i-1]));
			if(t[i] == 0){
				if(rd_a < d){
					rd_a = d;
					rt_a = f[i]-f[i-1];
				}
				else if(rd_a == d){
					rt_a = min ( rt_a , f[i]-f[i-1] );
				}
			}
			else {
				if(rd_b < d){
					rd_b = d;
					rt_b = f[i]-f[i-1];
				}
				else if(rd_b == d){
					rt_b = min ( rt_b , f[i]-f[i-1] );
				}
			}
		}
	}
	
	cout.precision(10);
	
	if(rd_a == -1)puts("-1 -1");
	else cout << sqrt((ld)rd_a) << " " << rt_a/60.0 << endl;
	if(rd_b == -1)puts("-1 -1");
	else cout << sqrt((ld)rd_b) << " " << rt_b/60.0 << endl;
}