Charlie the Cockchafer#4154

Charlie the Cockchafer

1 second
64 megabytes
Medium

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. The first line of each instance contains integers , and (1 \le N \le 1000, 1 \le S, T \le 1000), where is the number of straight cockchafer flight trajectories (also known as "cockridors"), is Charlie's speed in meters per second, and is the speed of him turning in degrees per second. The second line contains six integers (0 \le X_f, Y_f, Z_f, X_t, Y_t, Z_t \le 10000) indicating the starting point (X_f, Y_f, Z_f) and the destination (X_t, Y_t, Z_t).

Each of the following lines contains six integers 0 \le X_1, Y_1, Z_1, X_2, Y_2, Z_2 \le 10000 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 , 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 is the sum of the lengths of all segments traversed (in meters) and 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 the difference between and the answer computed by the judges is at most .

Examples

Example 1

Loading
Loading