Very New York

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

The year is 2211. Very New York is a city on Mars. The streets of the city make up a perfect grid. Each intersection in the city can be specified using a pair (x,y)(x,y) of integers. The distance between two intersections (x_1,y_1)(x\_1,y\_1) and (x_2,y_2)(x\_2,y\_2) equals x_1x_2+y_1y_2|x\_1-x\_2| + |y\_1-y\_2|.

An investor is interested in building a hotel in the city. Since hotel owners love to advertise hotels using phrases of the form "150 restaurants within half a mile", the investor wants to learn the number of restaurants within a specific distance from each of the prospective locations.

입력

The first line contains RR, the number of restaurants in the city (0R100,0000 \le R \le 100\\,000). The next RR lines describe the coordinates of one restaurant each. Each of these lines contains two integers xx and yy (1x,y1,000,0001 \le x,y \le 1\\,000\\,000).

The (R+2)(R+2)-nd line contains one integer QQ which is the number of queries (1Q100,0001 \le Q \le 100\\,000). The next QQ lines contain one query each. Each query consists of a triple of integers xx, yy, and dd (1x,y,d1,000,0001 \le x, y, d \le 1\\,000\\,000).

출력

The output should consist of QQ lines, each containing a single integer. The ii-th line should contain the answer to the ii-th query (x,y,d)(x,y,d): the number of restaurants at distance at most dd from (x,y)(x,y).