- Time limit: 1.00 s
- Memory limit: 512 MB
You are given a set of distinct points in the plane. Each point has integer coordinates between , and is either blue or red.
There are always four points with fixed coordinates: and , which are blue, and and , which are red. The other points may have any coordinates and colors, but there are never three points on the same line.
Your task is to add line segments, each of which connects two points of the same color, in such a way that all blue and red points belong to the same component, and no two line segments intersect.
Input
The first input line has two integers and : the number of points and the coordinate upper bound.
After this, there are lines that describe the points. Each line has three integers , and : a point is located at and its color is blue () or red ().
Output
Print lines that describe the connections. Each line must have four integers , , and : the points and are connected.
You can print any valid solution, and it can be proven that there is always a solution.
Constraints
Example
Input:
8 6 0 0 1 0 6 2 1 4 1 3 4 2 4 1 1 4 5 1 6 0 1 6 6 2
Output:
0 0 1 4 0 0 6 0 0 6 6 6 1 4 4 5 6 0 4 1 6 6 3 4
The following figure corresponds to this example: