P1847 Bombing II

Description

A city has been bombed $M$ times. Each time, the bombed area is a rectangle whose sides are parallel to the axes. After the bombings, there are $N$ key points. The commander wants to know whether each point has ever been bombed; if so, how many times it was bombed, and in which round it was last bombed.

Input Format

The first line contains two integers: $M, N$. Each of the next $M$ lines contains four integers: $x_1$, $y_1$, $x_2$, $y_2$, representing the top-left and bottom-right coordinates of the bombed rectangle (for example, `1 3 7 10` means the bombed area is the rectangle from $(1,3)$ to $(7,10)$). Then the next $N$ lines each contain two integers, representing the coordinates of a key point.

Output Format

Output $N$ lines. In each line, the first token is `YES` or `NO`, indicating whether the point was bombed. If it is `YES`, after a space output two integers: the number of times it was bombed, and the round number of the last bombing.

Explanation/Hint

$1 \le N, M \le 2000$ $1 \le x_1, y_1, x_2, y_2 \le 2^{32} - 1$ Translated by ChatGPT 5