Under construction

Still being built. Things may change

Towers

Time limit2sMemory limit1024 MB

Summary
Pick a subset of points for towers, with at most two towers per row or column, so every other point lies between two towers in its row or column.
Level

Medium7 of 10

Topics
Graph, DFS, Greedy
Solved
No attempts yet

Problem

Benson the Rabbit likes towers. There are NN cities numbered 11 to NN, and city ii is located at the point with integer coordinates (Xi,Yi)(X_i, Y_i). No two cities are located at the same point. Benson wants to build towers in some of these cities so that the following conditions hold.

  • For any aa, at most two towers have xx-coordinate equal to aa.
  • For any bb, at most two towers have yy-coordinate equal to bb.
  • Each of the NN cities either has a tower, or lies on the line segment between two towers with the same xx-coordinate or the same yy-coordinate. More formally, if city (x,y)(x, y) has no tower, then there are towers at (x,c)(x, c) and (x,d)(x, d) with c≤y≤dc \le y \le d, or towers at (e,y)(e, y) and (f,y)(f, y) with e≤x≤fe \le x \le f.

Input

The first line contains one integer NN, the number of cities.

The next NN lines are such that the ii-th line contains two integers XiX_i and YiY_i, meaning city ii is located at the point (Xi,Yi)(X_i, Y_i).

Output

Output one line containing a string of NN characters A1A2⋯ANA_1A_2 \cdots A_N. AiA_i is 11 if Benson builds a tower in city ii, and 00 otherwise. The towers built must satisfy all the conditions.

If there are several solutions, your program can output any one of them.

Constraints

  • 1≤N≤1061 \le N \le 10^6
  • 1≤Xi,Yi≤1061 \le X_i, Y_i \le 10^6
  • For all i≠ji \ne j, either Xi≠XjX_i \ne X_j or Yi≠YjY_i \ne Y_j.

Examples3

  1. Example 1

    Input
    3
    1 1
    1 6
    1 5
    
    Expected output
    110
    
  2. Example 2

    Input
    6
    1 1
    1 2
    2 1
    2 2
    3 1
    3 2
    
    Expected output
    110011
    
  3. Example 3

    Input
    8
    1 13
    2 13
    7 27
    7 13
    7 2
    2 27
    7 4
    4 13
    
    Expected output
    10101101