#include <bits/stdc++.h>
using namespace std;
#define MAX_TIME 324000*60
#define EPS 0.001

bool eq(double a, double b){
  return abs(a-b) < EPS;
}

int main(void){
  int N;
  double dist_A = -1.0, dist_B = -1.0;
  int time_A = MAX_TIME, time_B = MAX_TIME;
  cin >> N;
  int pref = -1, prea = -1, pret = -1;
  double prex = -1.0, prey = -1.0;
  while(N--){
    int f, a, t, x, y;
    cin >> f >> a >> t >> x >> y;
    if(pret == t && prea != a){
      if(t == 0){
        double dist = sqrt(pow(prex - x, 2) + pow(prey - y, 2));
        if(eq(dist_A, dist)){
          time_A = min(time_A, f - pref);
        }else{
          if(dist_A < dist){
            dist_A = dist;
            time_A = f - pref;
          }
        }
      }else{
        double dist = sqrt(pow(prex - x, 2) + pow(prey - y, 2));
        if(eq(dist_B, dist)){
          time_B = min(time_B, f - pref);
        }else{
          if(dist_B < dist){
          dist_B = dist;
          time_B = f - pref;
          }
        }
      }
    }
    pret = t; prea = a; pref = f; prex = x; prey = y;
  }
  if(eq(dist_A, -1.0)){
    cout << -1 << " ";
  }else{
    printf("%f ", dist_A);
  }
  if(time_A == MAX_TIME){
    cout << -1 << endl;
  }else{
    printf("%f\n", time_A/60.0);
  }
  if(eq(dist_B, -1.0)){
    cout << -1 << " ";
  }else{
    printf("%f ", dist_B);
  }
  if(time_B == MAX_TIME){
    cout << -1 << endl;
  }else{
    printf("%f\n", time_B/60.0);
  }
  return 0;
}