#P4475. Accepted Chocolates Deliciousness

    ID: 17721 Type: Default 1000ms 256MiB

Accepted Chocolates Deliciousness

Accepted Chocolates Deliciousness

In the Chocolate Kingdom, every chocolate is made from milk and cocoa. However, not every chocolate is welcomed by the people because they don't like overly sweet chocolates.

For each chocolate, let $$x$$ be the milk content and $$y$$ be the cocoa content. Each person assigns weights to milk and cocoa with parameters $$a$$ and $$b$$, so the sweetness level of a chocolate with milk $$x$$ and cocoa $$y$$ is given by $$ax+by$$. Moreover, each person has a sweetness threshold $$c$$; if a chocolate's sweetness level is greater than or equal to $$c$$, the person cannot accept it. Every chocolate also has a deliciousness value $$h$$.

Given the information of chocolates and people's preferences, compute for each person the sum of deliciousness values of all acceptable chocolates (i.e. those for which $$ax+by < c$$).

inputFormat

The first line contains two integers $$n$$ and $$m$$, representing the number of chocolates and the number of people respectively.

The next $$n$$ lines each contain three integers: $$x$$, $$y$$, and $$h$$, denoting the milk content, cocoa content, and deliciousness value of a chocolate.

The following $$m$$ lines each contain three integers: $$a$$, $$b$$, and $$c$$, representing a person's weights for milk and cocoa, and their sweetness threshold.

outputFormat

For each person, output a single line containing the total deliciousness value of the chocolates they can accept.

sample

3 2
1 2 10
2 1 20
1 1 15
1 1 4
2 2 5
15

0

</p>