Kattis

# Charlie the Cockchafer

Charlie knows how to fly. Despite this, whenever Charlie wants to move from one point to another, it becomes a tedious task for him. The main trouble is that Charlie is a cockchafer. And it is a well-known fact that all cockchafers (do not confuse them with cockroaches) are clumsy and slow. Not only they need some time to fly along a straight line, they also spend more time making turns. Knowing their limitations, will you help Charlie to find the quickest route?

## Input

The input consists of several instances, at most $12$. The first line of each instance contains integers $N$, $S$ and $T$ ($1 \leq N \leq 1\, 000, 1 \leq S, T \leq 1\, 000$), where $N$ is the number of straight cockchafer flight trajectories (also known as “cockridors”), $S$ is Charlie’s speed in meters per second, and $T$ is the speed of him turning in degrees per second. The second line contains six integers ($0 \leq X_ f, Y_ f, Z_ f, X_ t, Y_ t, Z_ t \leq 10\, 000$) indicating the starting point $(X_ f, Y_ f, Z_ f)$ and the destination $(X_ t, Y_ t, Z_ t )$.

Each of the following $N$ lines contains six integers $0 \leq X_1, Y_1, Z_1, X_2, Y_2, Z_2 \leq 10\, 000$ stating there is a line segment (cockridor) joining points $(X_1, Y_1, Z_1)$ with $(X_2, Y_2, Z_2)$. You are guaranteed that no internal point of the segment is an endpoint of another segment, and that both the initial and the final positions are endpoints of at least one of the segments. All coordinates are given in meters.

## Output

For each input instance, print a single line containing one real number $R$, giving the shortest time Charlie needs to get from the initial to the final point. Charlie can only move along the whole straight segments, all of them can be used in both directions. The time for any such path is $R = L/S + D/T$ seconds, where $L$ is the sum of the lengths of all segments traversed (in meters) and $D$ is the sum of the angles needed to turn between consecutive segments (in degrees). You can choose the initial and final direction that Charlie is facing, and assume that there always exists at least one path from the initial to the final point.

The answer will be accepted as correct if it has an absolute error of at most $0.001$.

Sample Input 1 Sample Output 1
1 3 1
0 0 0 10 10 10
0 0 0 10 10 10
2 3 1
0 0 0 10 10 10
0 0 0 0 10 10
10 10 10 0 10 10

5.773502692
98.047378541