#P1847. Bombing the City

    ID: 15130 Type: Default 1000ms 256MiB

Bombing the City

Bombing the City

A city is subjected to \(M\) bombings. Each bombing targets an axis-aligned rectangle, i.e. a rectangle whose edges are parallel to the coordinate axes. After the bombings, there are \(N\) key points. The commander wants to know for each key point:

  • Whether it has been bombed.
  • If yes, how many times it has been bombed and in which bombing round it was last hit.

A point is considered bombed by a rectangle if it lies within or on the boundary of the rectangle.

Note: The rectangles are given by two opposite corners. You should normalize their coordinates so that the first pair represents the lower-left corner and the second pair represents the upper-right corner.

inputFormat

The first line contains two integers \(M\) and \(N\) \( (1 \le M, N \le 10^5)\) representing the number of bombings and key points respectively. The following \(M\) lines each contain four integers \(x_1\), \(y_1\), \(x_2\), \(y_2\) indicating the coordinates of two opposite corners of a bombing rectangle. The following \(N\) lines each contain two integers \(x\) and \(y\) representing the coordinates of a key point.

outputFormat

For each key point, output two integers separated by a space. The first integer is the number of times the point was bombed and the second integer is the bombing round (1-indexed) when it was last bombed. If a point was never bombed, output "0 0".

sample

2 3
0 0 2 2
1 1 3 3
1 1
2 2
3 0
2 2

2 2 0 0

</p>