Business Website
题号:NC243994
时间限制:C/C++/Rust/Pascal 4秒,其他语言8秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

Cuber QQ hosted a business website by himself, to sell the own product of his own brand: QQ Cube.

The QQ Cube website may look like just any other harmless websites, but its true intent is evil. It's a blackmail website, which will enforce you to buy one of his products, otherwise you can't close it in your browser.

Specifically, the website has n webpages. On each of the n webpages, there is an introduction of one specific kind of product. At the bottom of the page, there are a few links. One of them must be buying the product on this page immediately. There can also be another few links (possibly none), which point to other pages on the website. If you click on the link, you will be redirected to another page. Of course, this is another page selling another kind of Cube product. As said before, there is no way to close the website before you pay for one of his products, at least not without damaging your computer.

After deploying the website, Cuber QQ, as the website manager wants to know the probabilities that people will end up buying each of his products. In other words, how likely is a customer to finally pay for the product on i-th page () if he slips into the home page (i.e., page 1) on the website? To formulate this, he has made some assumptions about the action probabilities on each page. After reading page i, a customer has  probability to follow the links to jump to page j. He also made an assumption that j would be always greater than i, so that people will not be able to jump back and forward forever. Therefore, if a customer has already jumped to page n, having nowhere else to go, he/she has no other choice but to buy the product on page n. A person will certainly not visit the website to buy two products, because no one will be so dumb to be blackmailed by the same website, twice.

Given the information above, please help Cuber QQ find out the probability of each product getting sold.

输入描述:

The input contains T test cases ().

For each test case, the first line contains one integer n (), indicating the number of pages.

The i-th of the following n-1 lines starts with an integer k_i (), which is the number of jumping links on i-th page. Then it's followed by k_i integer-floating number pairs:  ( is rounded to 6 digits after decimal point). It means that, when a person visits page i, it has probability  to jump to page . We guarantee that , and the probability that a person buys the i-th product immediately, is .

There are only n-1 lines instead of n lines because k_n must be 0.

The sum of all n, and the sum of all k_i from all test cases, are both no more than .

输出描述:

For each test case, output a line of n space-separated numbers, which are the probability that a customer ends up buying the i-th product (), respectively.

Each floating number will be considered correct if the absolute or relative error doesn't exceed .
示例1

输入

复制
1
3
2 2 0.300000 3 0.300000
1 3 0.500000

输出

复制
0.400000000 0.150000000 0.450000000

备注:

Large input and output. It's recommended to use scanf/printf instead of cin/cout if you are using C/C++.