Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

E. Lada Malina

time limit per test

5 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputAfter long-term research and lots of experiments leading Megapolian automobile manufacturer «AutoVoz» released a brand new car model named «Lada Malina». One of the most impressive features of «Lada Malina» is its highly efficient environment-friendly engines.

Consider car as a point in *Oxy* plane. Car is equipped with *k* engines numbered from 1 to *k*. Each engine is defined by its velocity vector whose coordinates are (*vx*_{i}, *vy*_{i}) measured in distance units per day. An engine may be turned on at any level *w*_{i}, that is a real number between - 1 and + 1 (inclusive) that result in a term of (*w*_{i}·*vx*_{i}, *w*_{i}·*vy*_{i}) in the final car velocity. Namely, the final car velocity is equal to

Formally, if car moves with constant values of *w*_{i} during the whole day then its *x*-coordinate will change by the first component of an expression above, and its *y*-coordinate will change by the second component of an expression above. For example, if all *w*_{i} are equal to zero, the car won't move, and if all *w*_{i} are equal to zero except *w*_{1} = 1, then car will move with the velocity of the first engine.

There are *n* factories in Megapolia, *i*-th of them is located in (*fx*_{i}, *fy*_{i}). On the *i*-th factory there are *a*_{i} cars «Lada Malina» that are ready for operation.

As an attempt to increase sales of a new car, «AutoVoz» is going to hold an international exposition of cars. There are *q* options of exposition location and time, in the *i*-th of them exposition will happen in a point with coordinates (*px*_{i}, *py*_{i}) in *t*_{i} days.

Of course, at the «AutoVoz» is going to bring as much new cars from factories as possible to the place of exposition. Cars are going to be moved by enabling their engines on some certain levels, such that at the beginning of an exposition car gets exactly to the exposition location.

However, for some of the options it may be impossible to bring cars from some of the factories to the exposition location by the moment of an exposition. Your task is to determine for each of the options of exposition location and time how many cars will be able to get there by the beginning of an exposition.

Input

The first line of input contains three integers *k*, *n*, *q* (2 ≤ *k* ≤ 10, 1 ≤ *n* ≤ 10^{5}, 1 ≤ *q* ≤ 10^{5}), the number of engines of «Lada Malina», number of factories producing «Lada Malina» and number of options of an exposition time and location respectively.

The following *k* lines contain the descriptions of «Lada Malina» engines. The *i*-th of them contains two integers *vx*_{i}, *vy*_{i} ( - 1000 ≤ *vx*_{i}, *vy*_{i} ≤ 1000) defining the velocity vector of the *i*-th engine. Velocity vector can't be zero, i.e. at least one of *vx*_{i} and *vy*_{i} is not equal to zero. It is guaranteed that no two velosity vectors are collinear (parallel).

Next *n* lines contain the descriptions of factories. The *i*-th of them contains two integers *fx*_{i}, *fy*_{i}, *a*_{i} ( - 10^{9} ≤ *fx*_{i}, *fy*_{i} ≤ 10^{9}, 1 ≤ *a*_{i} ≤ 10^{9}) defining the coordinates of the *i*-th factory location and the number of cars that are located there.

The following *q* lines contain the descriptions of the car exposition. The *i*-th of them contains three integers *px*_{i}, *py*_{i}, *t*_{i} ( - 10^{9} ≤ *px*_{i}, *py*_{i} ≤ 10^{9}, 1 ≤ *t*_{i} ≤ 10^{5}) defining the coordinates of the exposition location and the number of days till the exposition start in the *i*-th option.

Output

For each possible option of the exposition output the number of cars that will be able to get to the exposition location by the moment of its beginning.

Examples

Input

2 4 1

1 1

-1 1

2 3 1

2 -2 1

-2 1 1

-2 -2 1

0 0 2

Output

3

Input

3 4 3

2 0

-1 1

-1 -2

-3 0 6

1 -2 1

-3 -7 3

3 2 2

-1 -4 1

0 4 2

6 0 1

Output

4

9

0

Note

Images describing sample tests are given below. Exposition options are denoted with crosses, factories are denoted with points. Each factory is labeled with a number of cars that it has.

First sample test explanation:

- Car from the first factory is not able to get to the exposition location in time.
- Car from the second factory can get to the exposition in time if we set
*w*_{1}= 0,*w*_{2}= 1. - Car from the third factory can get to the exposition in time if we set , .
- Car from the fourth factory can get to the exposition in time if we set
*w*_{1}= 1,*w*_{2}= 0.

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Sep/21/2017 04:19:57 (c3).

Desktop version, switch to mobile version.

User lists

Name |
---|