{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e Recently, a new emerging game has become popular in Hogwarts. \u003cbr\u003e\u003cbr\u003e The goal of the game is to connect all islands in the ground with rainbows. At the beginning, n islands are isolated and the player arrive at the first island. There is a red magic set and a blue magic set on each island. Once the players of the game arrive at one of the islands, they will follow the sequence, which is firstly entering the red magic set, then the blue one. When a player enters the red magic set, he/she has the possibility of p to gain a rainbow, thereby two random island of all will be connected by the rainbow(including which two have been connected). When a player enters the blue magic set, he/she will be sent to one of the s islands with same possibility. One unit of total magic volume will be expended when the player uses the blue magic. At the end of the game, the winner is the one who consumes the least of total magic volume. \u003cbr\u003e\u003cbr\u003e However, the brilliant Hermione despises the game, she wants to know the expected magic volume to be taken away the goal of the game was achieved. \u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":" There are multiply test cases.\u003cbr\u003e\u003cbr\u003e The first line contains an integer T(T\u0026lt;\u003d100), indicates the number of cases. \u003cbr\u003eFor each case the first line contains an integer n, indicates the number of the islands. (1\u0026lt;\u003dn\u0026lt;\u003d20)\u003cbr\u003e\u003cbr\u003e Then there will be n numbers, pi indicates the possibility to gain a rainbow for the i-th island. (0\u0026lt;pi\u0026lt;1)\u003cbr\u003e\u003cbr\u003e The next n lines, each line firstly contains an integer s, then followed by s integers, indicates the number of which the i-th island can arrive at. (1 \u0026lt;\u003d s \u0026lt;\u003d n)"}},{"title":"Output","value":{"format":"HTML","content":" For each test case, you should output “Case #K: “ first, where K indicates the case number and counts from 1. Then output the answer. Round the answer to the sixth digit after the decimal point.\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n3\r\n0.123 0.984 0.63\r\n2 1 2\r\n2 2 3\r\n2 1 3\r\n2\r\n0.75 0.34\r\n2 1 2\r\n2 1 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 4.931167\r\nCase #2: 1.458716\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"If the player achieve the goal of the game, he/she won\u0027t enter the blue magic set anymore."}}]}