P1830 Bombing III

Background

A city of size $n\times m$ suffered $x$ bombings. Each time, a rectangle whose sides are parallel to the borders was bombed.

Description

After the bombings, there are $y$ key points. The commander wants to know whether each of them was ever bombed; if yes, how many times, and in which round the last time occurred.

Input Format

The first line contains four integers, $n,m,x,y$. The next $x$ lines each contain 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)$). The next $y$ lines each contain two integers, representing the coordinates of a key point.

Output Format

Output $y$ lines. In each line, the first character is `Y` or `N`, indicating whether it was bombed; if it is `Y`, then after a single space output two integers: the number of times it was bombed and the round number of the last time.

Explanation/Hint

For $100\%$ of the testdata, $1\le n,m\le 100$. Translated by ChatGPT 5