Beads

Beads of equal mass collide elastically on a line; find the position of the one marked red after t seconds.

Medium6SortingSimulationMathNo attempts yetTime limit2sMemory limit512 MB

Problem

Minjun runs a bead experiment on a frictionless number line of infinite length. There are NN beads. Each bead has negligible size, and all beads have the same mass. When two beads hit each other, the collision is perfectly elastic.

Minjun painted exactly one bead red. At time 00, bead ii is at position xix_i and starts moving with initial velocity viv_i. A bead changes its velocity only when it collides with another bead.

Find the position of the red bead after tt seconds.

Input

The first line contains the number of beads NN and the time tt. (1N1000001 \le N \le 100000, 1t1091 \le t \le 10^9)

Each of the next NN lines contains the position xix_i and the initial velocity viv_i of bead ii. (109xi,vi109-10^9 \le x_i, v_i \le 10^9)

The red bead is the one given first in the input. A negative viv_i means the bead moves in the x-x direction.

All given numbers are integers, and the bead positions are distinct.

Output

Print the position of the red bead after tt seconds. This value is guaranteed to be an integer.

Hint

A perfectly elastic collision conserves both momentum and kinetic energy. When two beads of equal mass collide perfectly elastically, they exchange velocities.

In the sample input the red bead hits bead 2 at time 2/72/7, bead 4 at time 22, bead 2 again at time 9/49/4, and bead 4 again at time 5/25/2. At time 33 it is at position 1212.