Polyline Simplification

Repeatedly remove the interior point whose triangle area is smallest, breaking ties by original index, and report each removal index.

Medium7HeapLinked listSimulationGeometryNo attempts yetTime limit5sMemory limit512 MB

Problem

Mapping applications represent the boundaries of countries and cities as polylines, which are connected sequences of line segments. Fine details have to be shown when the user zooms in, so such a polyline often contains a very large number of segments. When the user zooms out, those details do not matter, and processing and drawing a polyline with that many segments is wasteful. This problem uses one polyline simplification algorithm that approximates the original polyline with a polyline that has fewer segments.

A polyline with nn segments is described by n+1n + 1 points p0=(x0,y0),,pn=(xn,yn)p_0 = (x_0, y_0), \dots, p_n = (x_n, y_n), where the iith segment joins pi1p_{i-1} and pip_i. Removing an interior point pip_i (1in11 \le i \le n - 1) simplifies the polyline: the segments pi1pip_{i-1}p_i and pipi+1p_i p_{i+1} are replaced by the single segment pi1pi+1p_{i-1}p_{i+1}. Choose the point to remove like this. For every interior point pip_i, compute the area of the triangle formed by pi1p_{i-1}, pip_i and pi+1p_{i+1} (the area is 00 when the three points are colinear), and remove the point whose triangle has the smallest area. When several points have the smallest area, remove the one with the smallest index in the original polyline. Apply the same rule to the resulting polyline again, until the desired number mm of segments is left.

The figure below shows one step.

The original polyline is at the top. In the middle, the area of the triangle formed by p2p_2, p3p_3 and p4p_4 is measured, and p3p_3 is removed when that area is the smallest among all such triangles. The bottom shows the polyline after p3p_3 is removed.

Input

The first line contains two integers nn (2n2000002 \le n \le 200\,000) and mm (1m<n1 \le m < n). Each of the next n+1n + 1 lines describes one point, giving p0p_0 through pnp_n in order. A line holds the xx and yy coordinates of the point, both integers between 5000-5000 and 50005000 inclusive. The points are strictly increasing in lexicographic order. That is, for every 0i<n0 \le i < n, either xi<xi+1x_i < x_{i+1}, or xi=xi+1x_i = x_{i+1} and yi<yi+1y_i < y_{i+1}.

Output

Print nmn - m lines. On the kkth line print the index of the point removed in the kkth step of the algorithm above. Use the index the point has in the original polyline.