#P11329. Benson's Tower Construction

    ID: 13406 Type: Default 1000ms 256MiB

Benson's Tower Construction

Benson's Tower Construction

Rabbit \(\text{Benson}\) loves towers. In his country there are \(N\) cities located at coordinates \((X_i,Y_i)\) (no two cities share the same position). Benson wants to construct towers in some of these cities so that the following conditions are satisfied:

  • For every integer \(a\), at most two towers have an \(x\)-coordinate equal to \(a\);
  • For every integer \(b\), at most two towers have a \(y\)-coordinate equal to \(b\);
  • Every city either hosts a tower or lies on a line (parallel to one of the coordinate axes) between two towers. In other words, for a city at \((x,y)\) that does not have a tower, there must exist either two towers at \((x,c)\) and \((x,d)\) with \(c \le y \le d\), or two towers at \((e,y)\) and \((f,y)\) with \(e \le x \le f\).

It is guaranteed that a valid solution exists. Help Benson by finding a valid construction scheme.

inputFormat

The first line contains an integer \(N\), the number of cities. Each of the next \(N\) lines contains two integers \(X_i\) and \(Y_i\) representing the coordinates of a city.

outputFormat

Output a binary string of length \(N\). The \(i\)th character is '1' if a tower is built in the \(i\)th city and '0' otherwise. The output must correspond to a valid construction scheme.

sample

3
0 0
0 1
1 0
111