**2 人解决**，5 人已尝试。

**2 份提交通过**，共有 22 份提交。

**9.4** EMB 奖励。

**单点时限: **2.0 sec

**内存限制: **256 MB

Alice and Bob are going to drive from their home to a theater for a date. They are very challenging – they have no maps with them even though they don’t know the route at all (since they have just moved to their new home). Yes, they will be going just by their feeling.

The town they drive can be considered as an undirected graph with a number of intersections (vertices) and roads (edges). Each intersection may or may not have a sign. On intersections with signs, Alice and Bob will enter the road for the shortest route. When there is more than one such roads, they will go into one of them at random.

On intersections without signs, they will just make a random choice. Each random selection is made with equal probabilities. They can even choose to go back to the road they have just come along, on a random selection.

Calculate the expected distance Alice and Bob will drive before reaching the theater.

The input has the following format:

is the number of intersections (). and are the intersections the home and the theater are located respectively (); (for ) is either or , where denotes there is a sign at the -th intersection and denotes there is not; (for ) is a positive integer denoting the distance of the road connecting the -th and -th intersections, or indicating there is no road directly connecting the intersections. The distance of each road does not exceed .

Since the graph is undirectional, it holds for any . There can be roads connecting the same intersection, that is, it does not always hold . Also, note that the graph is not always planar.

Print the expected distance accurate to , or `impossible`

(without quotes) if there is no route to get to the theater. The distance may be printed with any number of digits after the decimal point.

Input

5 1 5 1 0 1 0 0 0 2 1 0 0 2 0 0 1 0 1 0 0 1 0 0 1 1 0 1 0 0 0 1 0

Output

8.50000000

**2 人解决**，5 人已尝试。

**2 份提交通过**，共有 22 份提交。

**9.4** EMB 奖励。

题目标签