Kattis

# Mountain Biking

Mount Snowdon, the tallest place in Wales, is a major attraction for mountain bikers far and wide. To take advantage of the popularity of this thrilling sport, an enterprising new venture plans to open several new bike repair shops throughout the rolling foothills.

The cunning small business owner’s financial success relates directly to the velocity of the average biker: the faster a biker is going at the foot of the hill the more likely they are to encounter a problem and have to walk — or sometimes limp — into the shop.

Snowdon, like most mountains, has a very angular sort of shape. In fact, the profile of the mountain can be represented as $N$ connected line segments pointing downward at various angles, each starting where the last left off. Given this highly scientific representation of the landscape, we need to find the likely speeds of bikers given that they may start off from the top of any of the $N$ segments.

As we all know, a biker on a $\theta$-degree slope from the vertical will accelerate at a rate of precisely $g \cdot \cos (\theta ) \; \; \textrm{m} \textrm{s}^{-2}$ along the slope.

## Input

• One line containing a positive integer $N$ ($1 \le N \le 4$), the number of line segments making up the mountain, followed by a space and then a real number $g$ ($1 \le g \le 100$), the coefficient of acceleration due to gravity.

• $N$ more lines each containing two integers $D_ i$ and then $\theta _ i$ ($1 \le D \le 10^4; 1 \le \theta \le 89$): the sloped distance in metres and absolute angle in degrees of this line segment from the vertical respectively. The segments are ordered from the top of the hill to its bottom.

## Output

Each of the $N$ lines of output should contain one real number: the velocity of a biker starting at the $i^{\text {th}}$-most segment from the top and finishing at the foot of the mountain.

Answers will be judged as correct if they are printed to within an absolute or relative difference of $10^{-6}$ from their exact values.

Sample Input 1 Sample Output 1
2 9
69 60
100 60

39.0
30.0

Sample Input 2 Sample Output 2
3 77
500 65
20 5
1000 80

249.70323
172.65601
163.52926