Sapper#8276

Sapper

1 секунда
64 мегабајти
Тешко

After successfully completing his tasks, Matvey decided to play "Minesweeper". The game features a square field of size N \times N, where some cells contain bombs. Your task is to efficiently answer queries about the number of bombs within a specified subrectangle. Since Matvey is still busy with other tasks, he needs your help to handle these queries.

Влез

First, an integer (1 \leq N \leq 10^5) is given, representing the size of the field. Then points with coordinates (X, Y) are provided, indicating the positions of the bombs, where all and are distinct (0 \leq X, Y \leq N - 1). After that, an integer (1 \leq M \leq 10^5) is given, representing the number of queries. The following lines contain queries in the format x_1\ y_1\ x_2\ y_2, specifying the corners of the subrectangle.

Излез

For each query, output a single line containing the number of bombs within the specified subrectangle.

Примери

Пример 1

Loading
Loading