QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓

#17731. Monotonically Increasing Tardiness Informatics Tournament

統計

The organizing beavers of the Monotonically Increasing Tardiness Informatics Tournament (MITIT) need to meet regularly to ensure that the contest runs smoothly, but they sometimes lose motivation.

problem_17731_1.png

There are $N$ organizing beavers who regularly have meetings that last exactly $M$ minutes. The $i^{\text{th}}$ beaver shows up $t_i$ minutes late on the first meeting. On each successive meeting, beaver $i$ comes $a_i$ minutes later than they did to the previous meeting. Output the first meeting where everyone is so late that they all miss the entire meeting.

A beaver is said to have missed the entire meeting if they arrive \textbf{at least} $M$ minutes late.

Input

The first line contains two space-separated integers $N$ ($ 1 \le N \le 2\cdot 10^5$) and $M$ ($ 1 \le M \le 10^9$).

The $i^{\text{th}}$ of the next $N$ lines contains two integers $t_i$ ($0 \le t_i < M$) and $a_i$ ($1 \le a_i \le 10^9$).

Output

Output one line with the answer.

Example

Input

4 60
0 9
30 4
10 12
14 9

Output

9

Notes

For the first meeting, Beaver $1$ arrives on time, Beaver $2$ arrives $30$ minutes late, Beaver $3$ arrives $10$ minutes late, and Beaver $4$ arrives $14$ minutes late. For meeting $9$, Beaver $1$ arrives $72$ minutes late, Beaver $2$ arrives $62$ minutes late, Beaver $3$ arrives $106$ minutes late, and Beaver $4$ arrives $86$ minutes late. This is the first meeting for which everyone arrives at least $60$ minutes late; for meeting $8$, Beaver $2$ arrives $58$ minutes late.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.