Dragonfly
문제
Dragonflies can be seen around ponds at Botanic Gardens and Bishan Park. In one of the denser forested areas, Benson the Rabbit has noted down ponds that the dragonflies fly around. At pond (1 ≤ i ≤ n), there are bugs that the dragonflies can eat. The bugs at pond belong to species .
Benson has also noted down trails. Each trail (1 ≤ j < n) connects 2 distinct ponds and bidirectionally. Dragonflies can travel from any pond to any other pond using only the trails.
Benson has captured dragonflies and intends to release them one at a time at pond . Dragonfly (1 ≤ k ≤ d) has a home pond of and will travel to pond without visiting any pond more than once using only the trails. These dragonflies will be released in increasing order from dragonfly to dragonfly . After a dragonfly is released, it will eat a single bug (if there is one or more bugs remaining) at every pond that it visits (including pond ), reducing the number of bugs at each of those ponds by if it is not .
Help Benson determine the number of distinct species of bugs eaten during the journey of each of the dragonflies.
입력
The input format is as follows:
- The first line of input contains spaced integers and respectively.
- The next line of input contains spaced integers .
- The next line of input contains spaced integers .
- The next line of input contains spaced integers .
- The next lines of input contains spaced integers each. The th of these lines contains and respectively.
출력
Output a single line with spaced integers. The th of these integers should be the number of distinct species of bugs eaten by the th dragonfly.
예제
예제 1
5 6 4 1 0 3 1 1 3 2 2 1 2 5 4 3 4 2 5 2 2 1 1 4 1 3
2 1 2 1 1 0
예제 2
7 4 0 2 4 4 0 1 3 6 1 6 2 2 2 1 7 5 2 4 4 1 4 5 6 2 1 6 1 3 6 7
2 1 1 1