QOJ.ac

QOJ

حد الوقت: 3 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#8358. Black and White Points

الإحصائيات

Given $n$ black points on a plane, perform $m$ operations, where each operation adds one white point.

After each addition, you need to find the minimum number of black and white points to remove such that there is no black point $(x, y)$ and white point $(x', y')$ satisfying $x \leq x'$ and $y \leq y'$.

Input

The first line contains an integer $n$, representing the number of black points.

The next $n$ lines each contain two integers $x_i, y_i$, representing the coordinates of the $i$-th black point.

The next line contains an integer $m$, representing the number of operations.

The next $m$ lines each contain two integers $x_i, y_i$, representing the coordinates of the white point added in the $i$-th operation.

Output

Output $m$ lines, each containing an integer representing the answer after the $i$-th operation.

Examples

Input 1

3
1 1
2 2
3 3
4
1 1
2 2
1 1
4 4

Output 1

1
2
2
3

Subtasks

Subtask ID $n, m \leq$ Special Property Score
$1$ $50$ None $13$
$2$ $1000$ None $28$
$3$ $100000$ All points $x_i = y_i$ $17$
$4$ $100000$ None $42$

For all data, it is guaranteed that $1 \leq n, m \leq 100000$ and $1 \leq x_i, y_i \leq 10^9$.

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.