13801380 SUSTech Online Judge
Problem 1380 --k-dimensional closest point distance

1380: k-dimensional closest point distance

Time Limit: 5 Sec  Memory Limit: 128 MB
Submit: 7  Solved: 3
[Submit][Status][Web Board]

Description

In a k-dimensional space, there are n points, find the square of the distance from the nearest point pair.

Input

The first line is the number of test T (1<=T<=5)

For each test:

In the first line, there will be two integers N(2<=N<=1e5), K(1<=K<=5).

N is the number of points. K is the size of the dimension.

In the next N lines, i-th line will have K integers {a1,a2,...,aj,...,ak-1,ak}, which means the coordinates of the i-th point.(-1e5<=aj<=1e5).

Output

Output the square of the distance from the nearest point pair.


Sample Input

2
2 1
1
1
3 3
1 2 3
2 3 4
3 4 5

Sample Output

0
3

HINT

Source

 

[Submit][Status]