Self-driving Car Sensor Blend

A self-driving car estimates the distance to the car ahead using two sources: a fast, reactive sensor (e.g., radar) and a slower but steadier signal (e.g., lidar/maps fused over time). To stabilize the distance, the car blends these two readings with a weight.

The first line of the input contains a single integer n - the number of reading pairs.

The second line contains a decimal w (0 ≤ w ≤ 1) - how much to trust the fast reading.

The next n lines each contain two numbers a b:

  • a: the fast reading (radar-like),

  • b: the slow reading (lidar/map-like).

For each pair, print the stabilized distance:

Input

Output

3
0.25
10 14
20 8
5 5

13
11
5

3
0.60
12 6
0 10
7.5 7.0

9.6
4
7.3

2
1
3 9
2.2 2.8

3
2.2

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue