#Lutece1480. Magic boy Bi Luo with his excited Zhu problem
Magic boy Bi Luo with his excited Zhu problem
Migrated from Lutece 1480 Magic boy Bi Luo with his excited Zhu problem
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
As we know, Bi Luo is a magic boy, he always has some excited questions , now a new question comes.
You are given a simple unrooted tree , Bi Luo wants you to caculate the excited value of the .
At the begining , excited value is , then for each non-empty subset of , we just think its vertex-induced subgraph , then we think each non-empty subset of again, we just think its vertex-induced subgraph , if is a connected graph and completely contained , then excited value adds [the number of vertexs in ] , otherwise do nothing.
Now, Bi Luo wants you to caculate the excited value of , can you help him?
Input
First Line is an positive integer , ( ) , represents there are test cases.
For each test case:
The first line contains two positive integers .( ) . represents there are vertexs.
The next line, each line contains two integers , ( ) , indicating there is an edge between and .
The next line contains integers , represents the elements of .( )
You may assume that there are no more than test cases with .
Output
For tht - test case , first output Case #i: ,then output one integer repretens the excited value,because the excited value may be large, so you only need to output the excited value of mod
Samples
3
1
1
2
1 2
1 1
3
1 2
2 3
1 1 1
Case #1: 1
Case #2: 5
Case #3: 16
Resources
“玲珑杯”ACM比赛 Round #2