4695: Optimal Point

内存限制:256 MB 时间限制:2 S
题面:传统 评测方式:文本比较 上传者:
提交:2 通过:2

题目描述

time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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 (x1,y1,z1) and (x2,y2,z2) is defined as |x1-x2|+|y1-y2|+|z1-z2|.
Input
The first line of the input contains an integer t t (1≤t≤100000)− 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 ni (1≤ni≤100000)− the number of roses in the test. Then follow ni 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 ni doesn't exceed 100000 and all coordinates are not greater than 1018 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.
Examples
Input
1
5
0 0 4
0 0 -4
0 4 0
4 0 0
1 1 1
Output
0 0 0
Input
2
1
3 5 9
2
3 5 9
3 5 9
Output
3 5 9
3 5 9
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.

输入样例 复制


输出样例 复制