Bitcoin Mining Fields

Given up to a million integer points, find the largest squared Euclidean distance between any two of them and print it.

Medium7GeometryMathNo attempts yetTime limit1sMemory limit64 MB

Problem

Bitcoin mining uses a lot of power. One day Ali and Betty decided to start their own mining fields in the center of Cheras, one field each. They went to Siva, the mayor of Cheras, to ask for locations.

Siva showed them a grid map with every possible location for a mining field. Mining draws a large amount of power, so Siva wants the two fields as far apart as possible to keep power spikes out of the neighbourhood.

Given the coordinates of all possible mining sites, find the largest Euclidean (straight line) distance between two of them. A site coordinate is always an integer.

Floating point arithmetic is easy to get slightly wrong, so you only have to output the square of that largest distance. The square of the Euclidean distance between two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) is defined as

(x1x2)2+(y1y2)2(x_1 - x_2)^2 + (y_1 - y_2)^2

Input

The first line has the number of possible mining sites NN (2N1062 \le N \le 10^6).

The second line has MM (2M15002 \le M \le 1500), the largest absolute value a coordinate can take, so every site satisfies MxM-M \le x \le M and MyM-M \le y \le M.

Each of the next NN lines has two integers XiX_i and YiY_i, the coordinates of one possible mining site. The same coordinate can appear more than once.

Output

Print the square of the Euclidean distance between the two farthest possible mining sites, as a single integer.