Problem7520--[CSES Problem Set] Nested Ranges Check

7520: [CSES Problem Set] Nested Ranges Check

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

Given $n$ ranges, your task is to determine for each range if it contains some other range and if some other range contains it.
Range $[a,b]$ contains range $[c,d]$ if $a≤c$ and $d≤b$.

Input

The first input line has an integer $n$: the number of ranges.
After this, there are $n$ lines that describe the ranges. Each line has two integers $x$ and $y$: the range is $[x,y]$.
You may assume that no range appears more than once in the input.

Output

First print a line that describes for each range (in the input order) if it contains some other range (1) or not (0).
Then print a line that describes for each range (in the input order) if some other range contains it (1) or not (0).

Constraints

$1≤n≤2⋅10^5$
$1≤x<y≤10^9$

Sample 1 Input

4
1 6
2 4
4 8
3 6

Sample 1 Output

1 0 0 0
0 1 0 1

HINT

相同题目:CSES 2168

Source/Category