Fair Chocolate-Cutting

You are given a flat piece of chocolate of convex polygon shape. You are to cut it into two pieces of precisely the same amount with a straight knife.

Write a program that computes, for a given convex polygon, the maximum and minimum lengths of the line segments that divide the polygon into two equal areas.

The figures below correspond to first two sample inputs. Two dashed lines in each of them correspond to the equal-area cuts of minimum and maximum lengths.

<image>
Figure F.1. Sample Chocolate Pieces and Cut Lines

Input

The input consists of a single test case of the following format.


$n$
$x_1$ $y_1$
...
$x_n$ $y_n$


The first line has an integer $n$, which is the number of vertices of the given polygon. Here, $n$ is between 3 and 5000, inclusive. Each of the following $n$ lines has two integers $x_i$ and $y_i$, which give the coordinates ($x_i, y_i$) of the $i$-th vertex of the polygon, in counterclockwise order. Both $x_i$ and $y_i$ are between 0 and 100 000, inclusive.

The polygon is guaranteed to be simple and convex. In other words, no two edges of the polygon intersect each other and interior angles at all of its vertices are less than $180^\circ$.

Output

Two lines should be output. The first line should have the minimum length of a straight line segment that partitions the polygon into two parts of the equal area. The second line should have the maximum length of such a line segment. The answer will be considered as correct if the values output have an absolute or relative error less than $10^{-6}$.

Sample Input 1


4
0 0
10 0
10 10
0 10


Sample Output 1


10
14.142135623730950488


Sample Input 2


3
0 0
6 0
3 10


Sample Output 2


4.2426406871192851464
10.0


Sample Input 3


5
0 0
99999 20000
100000 70000
33344 63344
1 50000


Sample Output 3


54475.580091580027976
120182.57592539864775


Sample Input 4


6
100 350
101 349
6400 3440
6400 3441
1200 7250
1199 7249


Sample Output 4


4559.2050019027964982
6216.7174287968524227






Example

Input

4
0 0
10 0
10 10
0 10


Output

10
14.142135623730950488
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}
P unit(const P &p){
    return p/abs(p);
}

double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}
P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}
double getarea(const VP &poly){
    double ret = 0;
    for (int i=0; i<(int)poly.size(); i++){ 
        ret += cross(poly[i], poly[(i+1)%poly.size()]);
    }
    return ret*0.5;
}
double gettriarea(P a, P b, P c){
    return (cross(a,b) +cross(b,c) +cross(c,a))*0.5;
}
VP convex_cut(const VP& p, const L& l){
    VP ret;
    int n = p.size();
    for(int i=0; i<n; i++){
        P curr = p[i];
        P next = p[(i+1)%n];
        if(ccw(l[0], l[1], curr) != -1) ret.push_back(curr);
        if(ccw(l[0], l[1], curr) *ccw(l[0], l[1], next) == -1){
            ret.push_back(crosspointLL(L(curr, next), l));
        }
    }
    return ret;
}

vector<L> split_to_lines(VP &p){
	int n = p.size();
    double halfarea = getarea(p)/2;
    vector<VP> cps(n);
    for(int i=0; i<n; i++){
        double currarea = 0;
        int opp;
        for(int j=2; j<n; j++){
        	double tmparea = gettriarea(p[i], p[(i+j-1)%n], p[(i+j)%n]);
        	if(currarea +tmparea > halfarea){
                opp = (i+j-1)%n;
                break;
            }
            currarea += tmparea;
        }
        double remarea = halfarea -currarea;
        double h = distanceLP(L(p[opp], p[(opp+1)%n]), p[i]);
        cps[opp].push_back(p[opp] +2*remarea/h *unit(p[(opp+1)%n] -p[opp]));
    }
    vector<L> ret;
    for(int i=0; i<n; i++){
    	cps[i].push_back(p[i]);
    	cps[i].push_back(p[(i+1)%n]);
    	sort(cps[i].begin(), cps[i].end());
    	cps[i].erase(unique(cps[i].begin(), cps[i].end()), cps[i].end());
    	if(cps[i][0] != p[i]){
    		reverse(cps[i].begin(), cps[i].end());
    	}
    	for(int j=0; j<(int)cps[i].size()-1; j++){
    		ret.emplace_back(cps[i][j], cps[i][j+1]);
    	}
    }
    return ret;
}

pair<double, double> minmax_cut(VP &p){
	vector<L> lines = split_to_lines(p);
    int n = lines.size();
    double halfarea = getarea(p)/2;
    double ansmin = INF;
    double ansmax = 0;
    for(int i=0; i<n/2; i++){
    	L s = lines[i];
    	L t = lines[(i+n/2)%n];
        ansmax = max(ansmax, max(abs(t[0]-s[0]), abs(t[1]-s[1])));
        double remarea = halfarea -getarea(convex_cut(p, L(t[0], s[1])));
        P lb = s[0];
        P ub = s[1];
        for(int r=0; r<100; r++){
        	P mid[2];
        	mid[0] = (lb+lb+ub) /3.0;
        	mid[1] = (lb+ub+ub) /3.0;
        	double len[2];
        	for(int d=0; d<2; d++){
        		double h = distanceLP(L(t[0], t[1]), mid[d]);
        		double l = 2*(remarea -gettriarea(mid[d], s[1], t[0])) /h;
        		len[d] = abs(mid[d] -(t[0] +l*unit(t[1]-t[0])));
        	}
        	if(len[0] < len[1]){
                ub = mid[1];
            }else{
            	lb = mid[0];
            }
            ansmin = min(ansmin, len[0]);
        }
    }
    return make_pair(ansmin, ansmax);
}

int main(){
    int n;
    cin >> n;
    VP p(n);
    for(int i=0; i<n; i++){
        int x,y;
        cin >> x >> y;
        p[i] = P(x, y);
    }
    auto ans = minmax_cut(p);
    cout << fixed << setprecision(10);
    cout << ans.first << endl;
    cout << ans.second << endl;
    return 0;
}
