Mushroom tractor

No attempts yetTime limit2sMemory limit32 MB

Problem

Mirko got a tractor for Christmas that can pick mushrooms. The mushrooms grow on a square meadow. In the coordinate plane that meadow is the square with lower left corner (1,1)(1, 1) and upper right corner (105,105)(10^5, 10^5).

At the start there is no mushroom on the meadow. Every second exactly one new mushroom grows on an empty spot, and NN of them grow in total. The ii-th mushroom grows at second ii.

Mirko wants to drive the tractor once and pick at least KK mushrooms. He starts at one of the lattice points of the meadow, and he moves only in a direction parallel to a side of the meadow or parallel to one of its diagonals. The tractor is so fast that the ride takes no time, and that speed also keeps him from turning during the ride. One ride therefore picks every mushroom on the line fixed by his starting point and his direction.

Find the smallest number of seconds after which Mirko can pick as many mushrooms as he wants.

Input

The first line contains the number of mushrooms that will grow NN and the number of mushrooms Mirko wants to pick KK. (2N1062 \le N \le 10^6, 2KN2 \le K \le N)

Each of the next NN lines contains the coordinates XiX_i and YiY_i of the ii-th mushroom to grow. (1Xi,Yi1051 \le X_i, Y_i \le 10^5) A mushroom grows only on an empty spot, so no two mushrooms have the same coordinates.

Output

Print the smallest required number of seconds. If Mirko cannot pick KK mushrooms in one ride, print -1.

Hint

In the first example Mirko starts at (1,2)(1, 2) and rides toward the mushroom at (4,5)(4, 5).