NNS - Nearest Neighbor Search
You are given N (N <= 100 000) d-dimensional (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 d-dimensional 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.Xi-B.Xi)*(A.Xi-B.Xi) for i=1, 2, ..., d.
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.
Print the answer for each of the Q queries on separate lines.
Input:2 2 2 1 1 2 2 1 1 3 3
Output: 0 2
@extazy: Constraints on d??