{"trustable":false,"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":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n When wake up, lxhgww find himself in a huge maze. \n \u003cbr\u003e \n \u003cbr\u003eThe maze consisted by N rooms and tunnels connecting these rooms. Each pair of rooms is connected by one and only one path. Initially, lxhgww is in room 1. Each room has a dangerous trap. When lxhgww step into a room, he has a possibility to be killed and restart from room 1. Every room also has a hidden exit. Each time lxhgww comes to a room, he has chance to find the exit and escape from this maze. \n \u003cbr\u003e \n \u003cbr\u003eUnfortunately, lxhgww has no idea about the structure of the whole maze. Therefore, he just chooses a tunnel randomly each time. When he is in a room, he has the same possibility to choose any tunnel connecting that room (including the tunnel he used to come to that room). \n \u003cbr\u003eWhat is the expect number of tunnels he go through before he find the exit? \n \u003cbr\u003e \n\u003c/div\u003e\n\u003cbr\u003e有n个房间,由n-1条隧道连通起来,从结点1出发,开始走,在每个结点i都有3种可能:\n\u003cbr\u003e1.被杀死,回到结点1处(概率为ki)\n\u003cbr\u003e2.找到出口,走出迷宫 (概率为ei)\n\u003cbr\u003e3.和该点相连有m条边,随机走一条 求:走出迷宫所要走的边数的期望值。\n"}},{"title":"Input","value":{"format":"HTML","content":"First line is an integer T (T ≤ 30), the number of test cases. \n\u003cbr\u003e \n\u003cbr\u003eAt the beginning of each case is an integer N (2 ≤ N ≤ 10000), indicates the number of rooms in this case. \n\u003cbr\u003e \n\u003cbr\u003eThen N-1 pairs of integers X, Y (1 ≤ X, Y ≤ N, X ≠ Y) are given, indicate there is a tunnel between room X and room Y. \n\u003cbr\u003e \n\u003cbr\u003eFinally, N pairs of integers Ki and Ei (0 ≤ Ki, Ei ≤ 100, Ki + Ei ≤ 100, K1 \u003d E1 \u003d 0) are given, indicate the percent of the possibility of been killed and exit in the ith room. \n\u003cbr\u003e\n\u003cbr\u003e第一行是一个整数T(T\u003c\u003d30),表示有T组测试数据\n\u003cbr\u003e在每一组测试数据的开头有一个整数N(2\u003c\u003dN\u003c\u003d1000),表示这个测试数据的房间数。\n\u003cbr\u003e然后有N-1对整数X,Y,(1\u003c\u003dX,Y\u003c\u003dN,X!\u003dY),表示X号房间和Y号房间有一条路。最后,有N对整数ki和ei(0\u003c\u003dki,ei\u003c\u003d100,ki+ei\u003c\u003d100,k1\u003de1\u003d0),表示在第i号房间,被杀死回到1号房间或者是走出迷宫的概率。\n"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output one line “Case k: ”. k is the case id, then the expect number of tunnels lxhgww go through before he exit. The answer with relative error less than 0.0001 will get accepted. If it is not possible to escape from the maze, output “impossible”. \n\u003cbr\u003e\n\u003cbr\u003e对于每组测试数据,应输出一行“Case k:”,k是这组测试数据的编号。\n\u003cbr\u003e然后输出在他走出迷宫前,走过的道路预计数量。\n\u003cbr\u003e误差可以在0.0001之内。如果他不能从迷宫中逃出,输出“impossible”"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e3\n3\n1 2\n1 3\n0 0\n100 0\n0 100\n3\n1 2\n2 3\n0 0\n100 0\n0 100\n6\n1 2\n2 3\n1 4\n4 5\n4 6\n0 0\n20 30\n40 30\n50 50\n70 10\n20 60\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003eCase 1: 2.000000\nCase 2: impossible\nCase 3: 2.895522\u003c/pre\u003e"}}]}