atcoder#RELAY2C. Garden

Garden

Score : 100100 points

Problem Statement

In your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant NN kinds of flowers in this empty flowerbed. For convenience, we will call these NN kinds of flowers Flower 1,1, 2,2, ,\cdots , NN. Also, we will call the position that is pp centimeters from the west end of the flowerbed Position pp.

You will plant Flower ii (1iN)(1 \leq i \leq N) as follows: first, plant one at Position wiw_i, then plant one every did_i centimeters endlessly toward the east. That is, Flower ii will be planted at the positions wi,w_i, wi+di,w_i + d_i, wi+2di,w_i + 2 d_i, \cdots Note that more than one flower may be planted at the same position.

Find the position at which the KK-th flower from the west is planted. If more than one flower is planted at the same position, they are counted individually.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1K1091 \leq K \leq 10^9
  • 1wi10181 \leq w_i \leq 10^{18}
  • 1di1091 \leq d_i \leq 10^9
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

NN KK

w1w_1 d1d_1

::

wNw_N dNd_N

Output

When the KK-th flower from the west is planted at Position XX, print the value of XX. (The westmost flower is counted as the 11-st flower.)

2 6
20 10
25 15
50

Two kinds of flowers are planted at the following positions:

  • Flower 11: Position 20,20, 30,30, 40,40, 50,50, 60,60, \cdots
  • Flower 22: Position 25,25, 40,40, 55,55, 70,70, 85,85, \cdots

The sixth flower from the west is the Flower 11 planted at Position 5050. Note that the two flowers planted at Position 4040 are counted individually.

3 9
10 10
10 10
10 10
30

Three flowers are planted at each of the positions 10,10, 20,20, 30,30, \cdots Thus, the ninth flower from the west is planted at Position 3030.

1 1000000000
1000000000000000000 1000000000
1999999999000000000