#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
int main(){
	int n;
	cin>>n;
	vvi in(n,vi(5));
	rep(i,n)rep(j,5)cin>>in[i][j];
	double ma[2]={-1,-1};
	int tim[2]={-60,-60};
	rep(i,n-1){
		if(in[i][1]!=in[i+1][1]&&in[i][2]==in[i+1][2]){
			int t=in[i][2];
			double a=hypot(in[i][3]-in[i+1][3],in[i][4]-in[i+1][4]);
			if(ma[t]<a){
				ma[t]=a;
				tim[t]=in[i+1][0]-in[i][0];
			}else if(abs(ma[t]-a)<EPS)tim[t]=min(tim[t],in[i+1][0]-in[i][0]);
		}
	}
	rep(i,2)printf("%.5f %.5f\n",ma[i],tim[i]/60.0);
}