CC BY 2.0 by GMG Creative on Flickr You and three friends have been playing the board game known as Boring Activity of Pure Chance (BAPC), a variant of Snakes and Ladders. BAPC takes place on a board with $$$n$$$ spaces numbered $$$1$$$ through $$$n$$$. All players start on space $$$1$$$, and they take turns rolling a die to determine how many spaces they advance. For example, if you are located on space $$$4$$$ and you roll a $$$3$$$, then you advance $$$3$$$ spaces, landing you on space $$$7$$$. If your roll has you advance beyond space $$$n$$$, you simply land on space $$$n$$$ instead. The first player to reach the finish at space $$$n$$$ wins.
The board also contains $$$m$$$ shortcuts. Each shortcut has an entrance space $$$a$$$ and an exit space $$$b$$$, and landing on the entrance space of a shortcut sends you to its exit space. The exit space can be either ahead of or behind the entrance space, either sending you forwards closer to the finish, or sending you backwards further from the finish. The entrance space cannot be $$$1$$$ or $$$n$$$, and it cannot coincide with the entrance or exit space of another shortcut.
You and your friends are getting bored of playing BAPC due to its simplicity. To make the game slightly more interesting, you have created four special dice. These dice are shaped like regular fair six-sided dice, but each die has its own selection of six numbers on the sides. Each player must choose one of the dice, and they must use that die for the entire duration of the game.
Before choosing the dice, the players agree on a player order, from player $$$1$$$ to player $$$4$$$. The players choose their die in reverse order, so player $$$4$$$ is first to pick a die, and player $$$1$$$ will get the final leftover die. After the dice have been distributed, the players take turns playing the game in their assigned order, so player $$$1$$$ begins, and player $$$4$$$ is last to play their first move.
To prevent the game from going on for too long, you also add a turn limit $$$t$$$. When each player has played $$$t$$$ turns and nobody has reached the finish, the game ends immediately, and the player located on the highest numbered space wins. In case multiple players are tied for highest numbered space, the player order breaks the tie, so that player $$$i$$$ beats player $$$j$$$ if $$$i \lt j$$$.
You have just started a game of BAPC, and you are assigned player $$$4$$$, so you are first to pick a die. Assuming every player picks the optimal die, maximizing their probability of winning, what is your probability of winning the game of BAPC?
As an example, consider the first sample case. The game lasts for only one turn, so the only way you can win as player $$$4$$$ is by throwing the highest number. Your optimal choice of die is thus the fourth die, giving you a $$$\frac16$$$ chance of throwing a $$$4$$$ and winning the game.
For the second sample case, it can be shown that each player has a $$$\frac14$$$ chance of winning, regardless of which die they pick.
The input consists of:
Output your probability of winning if every player picks the optimal die.
Your answer should have an absolute error of at most $$$10^{-6}$$$.
100 0 1 3 3 3 3 3 3 2 3 3 3 3 3 2 2 2 2 2 2 1 1 1 1 1 4
0.1666666666666667
20 3 2 0 0 0 8 8 8 1 1 2 2 3 3 0 0 0 7 7 7 5 5 5 5 5 5 5 13 8 12 19 1
0.25
2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0