CF853E Lada Malina
Description
After 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
$ (w_{1}·vx_{1}+w_{2}·vx_{2}+...+w_{k}·vx_{k}, w_{1}·vy_{1}+w_{2}·vy_{2}+...+w_{k}·vy_{k}) $ 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 Format
The first line of input contains three integers $ k,n,q $ ( $ 2
Output Format
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.
Explanation/Hint
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 $ .
