NNS  Nearest Neighbor Search
You are given N (N <= 100 000) ddimensional (1 <= d <= 5) points, each having integer coordinates (X1, X2, ..., Xd). Then Q (Q <= 100 000) queries follow. For each query you are given a ddimensional point (not necessarily from the given N) and you are to find the squared Euclidean distance to the closest point from the given N.
The coordinates of all N+Q points are generated randomly between 1 000 000 000 and 1 000 000 000.
The squred Euclidean distance between two points A and B is the sum of (A.XiB.Xi)*(A.XiB.Xi) for i=1, 2, ..., d.
Input
The first line contains three numbers  N, d and Q.
The next N lines contain d integers each  the coordinates of a point.
The next Q lines contain d integers each  the coordinates of a query point.
Output
Print the answer for each of the Q queries on separate lines.
Example
Input:2 2 22 2 2 1 1 2 2 1 1 3 31 12 23 3
Output: 0 2
hide comments
visleck:
20170829 11:33:25
@extazy: Constraints on d??

Added by:  Extazy 
Date:  20170829 
Time limit:  2s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 