F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Lotus and Islands

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 94    Accepted Submission(s): 4


Problem Description
There are $n$ islands in the world Lotus lives.Each island has a probability $p_i$ and a list consists of some other islands.
Lotus came to island 1 at first.She will repeat the following operations:
1ˇ˘Assume Lotus is in island $x$,there is a probability of $ p_x $ that produces an undirected edge connecting two random islands.The two islands will not be the same, nor will they already be connected by an edge.
2ˇ˘Lotus will leave contentedly if all the islands have been connected.
3ˇ˘Otherwise,she will choose an random island from the current island's list and go there.Her dissatisfied value will be increased by 1.
Lotus wants you to calculate the expected value of her dissatisfied value.
The $p_i$ is given in the prime field of integers modulo $10^9+7$.You should output the answer modulo $10^9+7$,too.
 

Input
First line a integer $T(0 \leq T \leq 10)$ denoting the number of test cases.
For each test case,first line is an integer $n(1 \leq n \leq 30)$,in the second line there are $n$ integers denoting $p_i$.Each of the next $n$ lines contains an integer $x$ followed by $x$ integers describing the island's list.
It is guaranteed that for each island,its list doesn't contain two same islands,nor do itself.
 

Output
For each test case,output one line containing a single integer,denoting the answer modulo $10^9+7$.
 

Sample Input
1 2 500000004 1 1 2 1 1
 

Sample Output
500000004
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-28 09:53:53, Gzip enabled