cho.sh
Notes
Loading...

Closest Points

Time limit

1s

Memory limit

128 MB

Problem

You are given N points in three-dimensional space. Find the squared distance between the closest pair of distinct positions, and count how many unordered pairs of distinct points achieve that distance.

The same coordinate may appear more than once in the input. Points with identical coordinates are considered to be the same point.

Input

The first line contains the number of points N. N is a positive integer not greater than 150,000.

Each of the next N lines contains the coordinates x, y, z of one point. The absolute value of each coordinate is at most 1,000,000.

Points with identical coordinates are treated as one point. The input always contains at least two distinct positions.

Output

Print the squared distance between the closest two points on the first line.

Print the number of unordered pairs of distinct points with that squared distance on the second line.

Only inputs whose closest squared distance is less than 1,000,000,000 are given.