This page is still under construction.

Parts of this page are still being built. What you see may change.

Factory

Interview

Time limit10sMemory limit512 MB

Summary
Find any point in the plane that minimizes the sum of Euclidean distances to n given store locations, within a relative error of 1e-6.
Level

Medium7 of 10

Topics
Geometry, Math, Binary search, Divide and conquer
Solved
No attempts yet

Problem

"ASD Inc." is a worldwide quadcopter manufacturer. They recently decided to build a new factory, which will make a brand new line of quadcopters. However, the company has not yet decided where to build it.

The factory should be placed in a location that makes the cost of delivering produced quadcopters to stores minimal. There are nn stores that are interested in selling the new model. The produced quadcopters will deliver themselves to the stores, each one flying straight from the factory to its selected store. If the Euclidean distance between the factory and some store equals xx, then the monthly cost of delivery is exactly xx bitcoins.

The factory can be built anywhere, even if there is some store at this point (in that case, delivery is costless). Given the coordinates of the stores, find the optimal place to build the factory.

Input

The first line of input contains the number of test cases zz (1≤z≤101 \leq z \leq 10). The descriptions of the test cases follow.

The first line of each test case contains the number of stores nn (2≤n≤10002 \leq n \leq 1000).

Each of the next nn lines contains two integers x,yx, y (−106≤x,y≤106-10^6 \leq x, y \leq 10^6) denoting coordinates of the stores.

You may assume that no two stores occupy the same spot.

Output

For each test case, output two numbers denoting the coordinates of a point which minimizes sum of distances to the stores. If there are multiple such points, output any one of them.

If the cost of the optimal solution is xx, then solution with cost yy will be considered correct if ∣y−xx∣<10−6|\frac{y-x}{x}| < 10^{-6}.

Examples1

  1. Example 1

    Input
    1
    3
    -3 0
    0 3
    3 0
    
    Expected output
    0.000000 1.732051