Crisis#969

Crisis

1 saniye
256 megabayt
Kolay

During an economic crisis on the planet Olympia, the exchange rate of the national currency (olymp) began to fluctuate against the intergalactic currency (galact). After the crisis ended, Petro, a resident of the planet, wanted to calculate how much he could have earned with his initial savings if he had known the daily exchange rates in advance.

Write a program that, given Petro's initial savings in olymps and the changes in the olymp-to-galact exchange rates, determines the maximum amount of money Petro could have at the end of the crisis. Fractional amounts of galacts cannot be bought or sold. By the end of the crisis, all funds must be converted back into olymps.

Giriş

The first line contains two integers: (1 \le N \le 50000) — the length of the crisis in days, and (1 \le S \le 100000) — the amount of Petro's initial savings in olymps. The next lines each contain two natural numbers, neither exceeding :

  1. The first number is the number of olymps required to purchase one galact on that day.

  2. The second number is the number of olymps received for selling one galact on that day. The second number does not exceed the first.

Çıktı

Output a single integer — the maximum amount of olymps Petro could have at the end of the last day of the crisis. It is guaranteed that the answer for each test case will not exceed 10^{18}.

Örnekler

Örnek 1

Loading
Loading