741. Closest Point

0

Medium

Your task is to find the m closest points to the origin on a cartesian plane. You are given an array of coordinates (X, Y) representing these points.

Input Format

The first line of input should contain two integers, n and m, representing the number of points and the number of closest points to find, respectively. The next n lines should contain the coordinates x[i] and y[i] of each point.

Output Format

Output the points in a sorted manner based on their X-coordinate.

Example

Input

3 2 3 3 5 -1 -2 4

Output

-2 4 3 3

Constraints

1 <= m <= points.length <= 10^4
-10^4 < x[i], y[i] < 10^4
Loading...

View Submissions

Console