This page is still under construction.

Parts of this page are still being built. What you see may change.

Dividing the Kingdom

Time limit2sMemory limit512 MB

Summary
Given n distinct integer-half points in the plane, output at most n-1 axis-parallel lines at integer coordinates so that no two points share a region.
Level

Medium7 of 10

Topics
Divide and conquer, Geometry, Sorting, Recursion
Solved
No attempts yet

Problem

The kingdom of Flatland is an infinite two-dimensional plane. The kingdom has nn castles. To make mapmaking easier, Flatland introduced a Cartesian coordinate system. Castle ii sits at the point with coordinates (xi+0.5,yi+0.5)(x_i+0.5, y_i+0.5), where xix_i and yiy_i are integers. All castle locations are pairwise distinct.

In his old age, the king decided to divide the kingdom on the map among his sons using lines parallel to the coordinate axes. If a line is parallel to the OxOx axis, then the yy coordinate of every point on it must be an integer; otherwise the xx coordinate of every point must be an integer. In both cases the absolute value of the relevant integer coordinate must not exceed 2⋅1092 \cdot 10^9. The king also wants any two castles to end up in different parts after the division.

Help the king divide the kingdom using at most n−1n-1 lines. Any pair of lines must share at most one point.

Input

The first line contains the integer nn (1≤n≤100 0001 \le n \le 100\,000), the number of castles in the kingdom. The next nn lines contain two numbers xix_i and yiy_i (−109≤xi≤109-10^9 \le x_i \le 10^9, −109≤yi≤109-10^9 \le y_i \le 10^9), the integer parts of the castle coordinates.

Output

On the first line, output the number of lines used. On the following lines, output the lines themselves, one per line. If a line is parallel to the OxOx axis, output the character y, then a space, then the yy coordinate of every point on that line. Otherwise output the character x, then a space, then the xx coordinate of every point on that line.

Hint

Examples1

  1. Example 1

    Input
    4
    0 2
    0 3
    1 2
    1 3
    
    Expected output
    2
    x 1
    y 3