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
webpages. On each of the
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
-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
, a customer has
probability to follow the links to jump to page
. He also made an assumption that
would be always greater than
, so that people will not be able to jump back and forward forever. Therefore, if a customer has already jumped to page
, having nowhere else to go, he/she has no other choice but to buy the product on page
. 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
test cases (
).
For each test case, the first line contains one integer
(
), indicating the number of pages.
The
-th of the following
lines starts with an integer
(
), which is the number of jumping links on
-th page. Then it's followed by
integer-floating number pairs:
(
,
,
is rounded to 6 digits after decimal point). It means that, when a person visits page
, it has probability
to jump to page
. We guarantee that
, and the probability that a person buys the
-th product immediately, is
.
There are only
lines instead of
lines because
must be 0.
The sum of all
, and the sum of all
from all test cases, are both no more than
.
输出描述:
For each test case, output a line of
space-separated numbers, which are the probability that a customer ends up buying the
-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++.