QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#14734. hlcpq

統計

Given $n$ horizontal line segments and $n$ vertical line segments on a plane, it is guaranteed that no two segments lie on the same line.

Two segments are connected if they intersect. If $a$ and $b$ are connected, and $b$ and $c$ are connected, then $a$ and $c$ are connected.

A segment $a$ is critical if and only if there exist two other segments $b$ and $c$ such that $b$ and $c$ are connected, but $b$ and $c$ are no longer connected after removing $a$.

Input

The first line contains an integer $n$.

The next $n$ lines each contain two integers $l$ and $r$ ($1 \le l < r \le n$), representing a horizontal line segment $l \le x \le r$ at $y=i$ (for the $i$-th horizontal segment).

The next $n$ lines each contain two integers $d$ and $u$ ($1 \le d < u \le n$), representing a vertical line segment $x=i$ at $d \le y \le u$ (for the $i$-th vertical segment).

Output

Output two lines, each being a binary string of length $n$.

The $i$-th character of the first line is $1$ if and only if the $i$-th horizontal segment is critical, and $0$ otherwise.

The $i$-th character of the second line is $1$ if and only if the $i$-th vertical segment is critical, and $0$ otherwise.

Examples

Input 1

10
1 4
2 7
1 6
3 7
2 4
1 9
1 3
9 10
3 5
1 7
1 7
1 3
1 3
3 7
1 2
3 5
1 7
5 7
3 9
9 10

Output 1

0100010000
1001000010

Subtasks

For $100\%$ of the data, $2 \le n \le 10^5$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.