Walking Trail

Time limit1sMemory limit128 MB

Problem

The government wants to build walking trails through an oak forest. The forest can be represented as a plane, and the N trees stand on distinct lattice points.

A walking trail is represented by an axis-aligned rectangle. Trees on the boundary of the rectangle must be cut down, but trees strictly inside the rectangle do not need to be cut.

The forest office received P walking-trail plans. For each plan, determine how many trees must be cut down to build that trail. Only trees on the rectangle boundary are cut.

Input

The first line contains the number of trees N. (1 <= N <= 300,000)

Each of the next N lines contains the coordinates X and Y of one tree. No two trees are at the same point. (1 <= X, Y <= 10^9)

The next line contains the number of submitted walking-trail plans P. (1 <= P <= 100,000)

Each of the next P lines contains X1, Y1, X2, Y2. (1 <= X1 < X2 <= 10^9, 1 <= Y1 < Y2 <= 10^9) (X1, Y1) is the lower-left coordinate of the rectangle, and (X2, Y2) is the upper-right coordinate.

Output

Print P lines. For each walking-trail plan, in input order, print the number of trees that must be cut down.

Hint