Codeforces Round 359 (Div. 1)
C
Optimal Point
Codeforces
2900
原题
← BD →
翻译中…

When the river brought Gerda to the house of the Old Lady who Knew Magic, this lady decided to make Gerda her daughter. She wants Gerda to forget about Kay, so she puts all the roses from the garden underground.

翻译中…

Mole, who lives in this garden, now can watch the roses without going up to the surface. Typical mole is blind, but this mole was granted as special vision by the Old Lady. He can watch any underground objects on any distance, even through the obstacles and other objects. However, the quality of the picture depends on the Manhattan distance to object being observed.

翻译中…

Mole wants to find an optimal point to watch roses, that is such point with integer coordinates that the maximum Manhattan distance to the rose is minimum possible.

翻译中…

As usual, he asks you to help.

翻译中…

Manhattan distance between points $(*x*_{1},  *y*_{1},  *z*_{1})$ and $(*x*_{2},  *y*_{2},  *z*_{2})$ is defined as $|*x*_{1} - *x*_{2}| + |*y*_{1} - *y*_{2}| + |*z*_{1} - *z*_{2}|$.

翻译中…

Input

翻译中…

The first line of the input contains an integer $*t*$ $*t*$ ($1 ≤ *t* ≤ 100 000$) — the number of test cases. Then follow exactly $*t*$ blocks, each containing the description of exactly one test.

翻译中…

The first line of each block contains an integer $*n*_{*i*}$ ($1 ≤ *n*_{*i*} ≤ 100 000$) — the number of roses in the test. Then follow $*n*_{*i*}$ lines, containing three integers each — the coordinates of the corresponding rose. Note that two or more roses may share the same position.

翻译中…

It's guaranteed that the sum of all $*n*_{*i*}$ doesn't exceed $100 000$ and all coordinates are not greater than $10^{18}$ by their absolute value.

翻译中…

Output

翻译中…

For each of $*t*$ test cases print three integers — the coordinates of the optimal point to watch roses. If there are many optimal answers, print any of them.

翻译中…

The coordinates of the optimal point may coincide with the coordinates of any rose.

翻译中…

Note

翻译中…

In the first sample, the maximum Manhattan distance from the point to the rose is equal to $4$.

翻译中…

In the second sample, the maximum possible distance is $0$. Note that the positions of the roses may coincide with each other and with the position of the optimal point.

翻译中…

样例

Input #1
1
5
0 0 4
0 0 -4
0 4 0
4 0 0
1 1 1
Output #1
0 0 0
InputCopy OutputCopy
Input #2
2
1
3 5 9
2
3 5 9
3 5 9
Output #2
3 5 9
3 5 9
InputCopy OutputCopy
题目信息
题号
685C
时间限制
3 s
内存限制
256 MB
标签
二分
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。