Problem:
Score : 800 points

Problem Statement

There are N lines in the xy-plane. The i-th line is represented by A_ix+B_iy=C_i.
Any two lines among the N+2 lines, the above N lines plus the x-axis and y-axis, cross each other at exactly one point.

For each pair 1 \leq i < j \leq N, there is a car at the cross point of the i-th and j-th lines.
Even where three or more lines intersect at a point, a car is individually placed for each pair of lines.
That is, there will be k(k-1)/2 cars placed at the intersection of k lines.

Those cars are already very old, and can only be moved parallel to the x-axis or y-axis.

Takahashi will hold an exhibition of antique cars at a place on the xy-plane.
In order to avoid damaging the half-broken cars too much, he will select the place of the exhibition so that the total distance covered will be minimized when all the cars are moved to the place.
If such a place is not uniquely determined, among the places that satisfy the condition above, the place with the minimum x-coordinate will be selected.
If the place is still not uniquely determined, among the places that satisfy the two conditions above, the place with the minimum y-coordinate will be selected.

Find the place of the exhibition that will be selected.

Constraints

2 \leq N \leq 4 × 10^4

1 \leq |A_i|,|B_i| \leq 10^4(1 \leq i \leq N)

0 \leq |C_i| \leq 10^4(1 \leq i \leq N)

No two given lines are parallel.

All input values are integers.

Inputs

Input is given from Standard Input in the following format:

N
A_1 B_1 C_1
:
A_N B_N C_N

Outputs

Print the x-coordinate and y-coordinate of the place of the exhibition that will be selected, in this order, with a space in between. The output will be judged as correct when the absolute or relative error is at most 10^{-9}.

Sample Input 1

3
1 1 1
2 -1 2
-1 2 2

Sample Output 1

1.000000000000000 1.000000000000000

There is a car at each place shown by a blue circle in the figure. The place to be selected is shown by a purple circle.

Sample Input 2

4
1 1 2
1 -1 0
3 -1 -2
1 -3 4

Sample Output 2

-1.000000000000000 -1.000000000000000

Sample Input 3

7
1 7 8
-2 4 9
3 -8 -5
9 2 -14
6 7 5
-8 -9 3
3 8 10

Sample Output 3

-1.722222222222222 1.325000000000000

Solution in C (GCC 5.4.1) (judge verdict: Runtime Error)

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_LINE_MAX		10000									// 最大直線数
#define D_POINT_MAX		50000000								// 最大座標数

// 内部構造体 - 直線情報
typedef struct Line {
	double mdX1, mdY1;											// 座標１
	double mdX2, mdY2;											// 座標２
} Line;

// 内部構造体 - 座標情報
typedef struct Point {
	double mdX, mdY;											// 座標
} Point;

// 内部変数
static FILE *szpFpI;											// 入力
static Line sz1Line[D_LINE_MAX];								// 直線
static int siLCnt;												// 直線数
static Point sz1Point[D_POINT_MAX];								// 座標
static int siPCnt;												// 座標数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 比較関数 - X昇順
int
fCmpFncXu(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	Point *lzpVal1 = (Point *)pzpVal1;
	Point *lzpVal2 = (Point *)pzpVal2;

	// X昇順
	if (lzpVal1->mdX > lzpVal2->mdX) {
		return 1;
	}
	else if (lzpVal1->mdX < lzpVal2->mdX) {
		return -1;
	}

	return 0;
}

// 比較関数 - Y昇順
int
fCmpFncYu(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	Point *lzpVal1 = (Point *)pzpVal1;
	Point *lzpVal2 = (Point *)pzpVal2;

	// Y昇順
	if (lzpVal1->mdY > lzpVal2->mdY) {
		return 1;
	}
	else if (lzpVal1->mdY < lzpVal2->mdY) {
		return -1;
	}

	return 0;
}

// 線分と線分の交点取得
int
fGetCrsLine(
	double pdSx1				// <I> 線分１始点Ｘ
	, double pdSy1				// <I> 線分１始点Ｙ
	, double pdEx1				// <I> 線分１終点Ｘ
	, double pdEy1				// <I> 線分１終点Ｙ
	, double pdSx2				// <I> 線分２始点Ｘ
	, double pdSy2				// <I> 線分２始点Ｙ
	, double pdEx2				// <I> 線分２終点Ｘ
	, double pdEy2				// <I> 線分２終点Ｙ
	, double *pdpX				// <O> 交点Ｙ
	, double *pdpY				// <O> 交点Ｙ
)
{
	// ベクトル
	double ldBx1 = (pdEx1 - pdSx1);
	double ldBy1 = (pdEy1 - pdSy1);
	double ldBx2 = (pdEx2 - pdSx2);
	double ldBy2 = (pdEy2 - pdSy2);
	double ldKx = (pdSx2 - pdSx1);
	double ldKy = (pdSy2 - pdSy1);
	double ldVal = ldBx2 * ldBy1 - ldBy2 * ldBx1;

	// 交点取得
	double ldP1 = (ldBx2 * ldKy - ldBy2 * ldKx) / ldVal;
	double ldP2 = (ldBx1 * ldKy - ldBy1 * ldKx) / ldVal;
	*pdpX = pdSx1 + ldBx1 * ldP1;
	*pdpY = pdSy1 + ldBy1 * ldP1;

	return 0;
}

// 集合地点 - 取得
double
fGetPos(
	int piXY					// <I> [0]:X [1]:Y
)
{
	// 座標 - ソート
	if (piXY == 0) {
		qsort(sz1Point, siPCnt, sizeof(Point), fCmpFncXu);
	}
	else {
		qsort(sz1Point, siPCnt, sizeof(Point), fCmpFncYu);
	}

	// 集合地点
	int liNo = (siPCnt - 1) / 2;
	if (piXY == 0) {
		return sz1Point[liNo].mdX;
	}
	else {
		return sz1Point[liNo].mdY;
	}
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// 直線数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siLCnt);

	// 直線 - 取得
	for (i = 0; i < siLCnt; i++) {
		double ldA, ldB, ldC;
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%lf%lf%lf", &ldA, &ldB, &ldC);
		sz1Line[i].mdX1 = 0.0;
		sz1Line[i].mdY1 = ldC / ldB;
		sz1Line[i].mdX2 = 1.0;
		sz1Line[i].mdY2 = (ldC - ldA) / ldB;
	}

	// 座標 - セット
	siPCnt = 0;
	for (i = 0; i < siLCnt; i++) {
		for (j = i + 1; j < siLCnt; j++) {
			fGetCrsLine(sz1Line[i].mdX1, sz1Line[i].mdY1, sz1Line[i].mdX2, sz1Line[i].mdY2, 
				sz1Line[j].mdX1, sz1Line[j].mdY1, sz1Line[j].mdX2, sz1Line[j].mdY2, &sz1Point[siPCnt].mdX, &sz1Point[siPCnt].mdY);
			siPCnt++;
		}
	}

	// 集合地点 - 取得
	double ldX = fGetPos(0);
	double ldY = fGetPos(1);

	// 出力
	sprintf(lc1Buf, "%.10lf %.10lf\n", ldX, ldY);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}