P14957 [Template] Offline Static 4D Point Counting
Description
There are $n$ rectangles on the plane; the $i$-th rectangle has lower-left corner $x_{i,1},y_{i,1}$ and upper-right corner $x_{i,2},y_{i,2}$.
There are $m$ queries; the $j$-th query gives a rectangle with lower-left corner $X_{j,1},Y_{j,1}$ and upper-right corner $X_{j,2},Y_{j,2}$, and asks how many of the rectangles on the plane completely contain the rectangle given by the query.
A rectangle with lower-left corner $x_{i,1},y_{i,1}$ and upper-right corner $x_{i,2},y_{i,2}$ contains the rectangle with lower-left corner $X_{j,1},Y_{j,1}$ and upper-right corner $X_{j,2},Y_{j,2}$ if and only if $x_{i,1}\le X_{j,1}$, $y_{i,1}\le Y_{j,1}$, $X_{j,2}\le x_{i,2}$, and $Y_{j,2}\le y_{i,2}$.
Input Format
The first line contains two numbers $n,m$.
The next $n$ lines, where the $i$-th line contains four numbers representing $x_{i,1},y_{i,1},x_{i,2},y_{i,2}$.
The next $m$ lines, where the $j$-th line contains four numbers representing $X_{j,1},Y_{j,1},X_{j,2},Y_{j,2}$.
Output Format
For each query, output a single line with one number, the answer.
Explanation/Hint
For $20\%$ of the data, $n,m\le 1000$.
For another $20\%$ of the data, $n,m\le 10^4$.
For another $20\%$ of the data, $n,m\le 10^5$.
For another $20\%$ of the data, $n,m\le 2\times10^5$.
For $100\%$ of the data, $1\le n,m\le 4\times10^5$.
It is guaranteed that $x_{i,1}\le x_{i,2}$, $y_{i,1}\le y_{i,2}$, $X_{i,1}\le X_{i,2}$, $Y_{i,1}\le Y_{i,2}$.
All input numbers are within $[1,10^9]$.
Translated by QwenWork