*Light*Young*Woo*

Given N lights that each illuminate a 90-degree upward sector, count for each query point how many sectors contain it.

Medium5GeometryPrefix sumBinary searchSortingNo attempts yetTime limit1sMemory limit512 MB

Problem

Let north be the +y+y direction. There are NN lights in the plane, with the ii-th light at (Xi,Yi)(X_i, Y_i).

Each light illuminates a 9090-degree sector centered on north. A point (X,Y)(X, Y) receives light from the ii-th light exactly when

YYiandXXiYYiY \ge Y_i \quad \text{and} \quad |X - X_i| \le Y - Y_i

The boundary is included, so the point where a light stands is illuminated by that light. When several lights cover the same point, their intensities add up. That is, the intensity at (X,Y)(X, Y) equals the number of lights satisfying the condition above.

Input

The input is given from standard input. The first line contains the number of lights NN (1N1000001 \le N \le 100000).

The next NN lines each contain two integers Xi,YiX_i, Y_i (1500Xi,Yi1500-1500 \le X_i, Y_i \le 1500), the position of each light.

The next line contains the number of query points PP (1P1000001 \le P \le 100000).

The next PP lines each contain two integers Xpi,YpiX_{pi}, Y_{pi} (1500Xpi,Ypi1500-1500 \le X_{pi}, Y_{pi} \le 1500), the coordinates of each point whose intensity is asked.

Output

Print PP lines to standard output. The ii-th line contains the light intensity at (Xpi,Ypi)(X_{pi}, Y_{pi}).