Problem J. Sindar's Art Exhibition
时间限制 1 ms
内存限制 64 MB
Sindar is an excellent artist and she has many works. One day she decides to hold an exhibition tour in her country. Her country is a tree, the nodes of which are the cities and the edges between the nodes are the roads between cities.
The value of an exhibition are determined by the number of works on the exhibition and the citizens' favorability of art. Generally speaking, if there are $m$ works in the exhibition, and the citizens' favorability is $k$, then the value of the exhibition will be $m*k$.
Her tour will begin at city $s$ and end in city $t$. She will begin the tour with $x$ works, but after she holds the exhibition in every city, she will choose $y_i$ suitable works and donate them to the local orphanage, which means that there will be only $x-y_i$ works when she holds the next exhibition, and $x-y_i-y_j$ works in the exhibition after the next, supposing that she will pass city $j$ after city $i$.
Now she has many tours and she want to know every tour's value mod $10^9+7$. And sometimes she may change one city's favorability.
输入数据
输出数据
For each query, output one interger indicates the tour's value mod $10^9+7$
样例输入
复制
1
6
1 2 1 4 5 6
1 1 1 2 2 2
1 2
2 4
2 5
5 6
1 3
2
2 3 3
1 6 3 10
样例输出
样例说明
$ Mathjax font initiator $