Gats and the Cozy Corridors
Gats has found a network of soft cushions connected by yarn corridors. Each cushion has a coziness and contains drops of milk. Each corridor connects cushions and and has steadiness .
Gats receives several independent queries. For a query :
- A cushion is welcoming if .
- A corridor is safe if .
For each query, report the sum of over all cushions that Gats can reach. Milk is not consumed, and all queries are independent.
Input
The first line contains three integers , , and (, , ), the number of cushions, corridors, and queries.
Output
For each query in order from to , print one integer: the total number of drops of milk over all cushions reachable by Gats in that query.
Samples
Sample 1
Input
4 3 3 5 3 4 2 10 7 1 8 1 2 3 2 3 4 3 4 2 1 3 4 3 3 4
Output
18 0 1
In the first query, Gats starts at cushion with mood . Cushions , , and are welcoming, and they are connected by safe corridors, so the total is . In the second query, cushion is not welcoming for mood .