406232: GYM102319 B Paul's Badminton

Memory Limit:256 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Paul's Badmintontime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Paul is running a quaint business that delivers badminton rackets. There are n places of interest between which he will deliver rackets. These n places are connected by only n - 1 bidirectional roads because Paul's country does not believe in roads.

Paul has m employees. The i'th employee has an order to deliver rackets from place ai to place bi, making one trip from place ai to place bi every day, from day si to day ti inclusive.

Paul's country believes in tolls. Every day, if any of Paul's employees uses the j'th road, Paul must pay an exorbitant toll of $1 for that road. Fortunately, each toll must only be paid once per day. In other words, if Paul pays the toll for road j for some day, then any number of his employees may use that road during that day with no extra cost.

Paul wants to know some details on the amount of money he needs to pay for these tolls, so he gives you q queries. For the jth query, he asks you how much money he needs to pay from day cj to day dj inclusive. Send help.

Input

The first line of input contains two space-separated integers n, m, and q (2 ≤ n ≤ 105 and 1 ≤ m, q ≤ 105), the number of places, employees, and queries respectively.

Each of the next n - 1 lines of input contains two space-separated integers x and y (1 ≤ x, y ≤ n), which means that there is a road connecting places x and y.

Each of the next m lines of input contains four space-separated integers ai, bi, si, and ti (1 ≤ ai, bi ≤ n and 1 ≤ si ≤ ti ≤ 109), representing the order for the i'th employee. It is guaranteed that ai ≠ bi.

Each of the next q lines of input contains two space-separated integers cj and dj (1 ≤ cj ≤ dj ≤ 109), representing Paul's j'th query.

Output

The output should contain q lines. The j'th line should contain a single integer which is the answer to the j'th query (in the order given in the input).

ExampleInput
5 3 3
1 2
3 2
1 4
1 5
2 5 4 7
3 4 2 5
2 3 6 9
7 11
3 6
5 5
Output
5
14
4

加入题单

算法标签: