CF1153A.Serval and Bus

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for this poor little boy is to wait for a bus on this rainy day. Under such circumstances, the poor boy will use the first bus he sees no matter where it goes. If several buses come at the same time, he will choose one randomly.

Serval will go to the bus station at time tt , and there are nn bus routes which stop at this station. For the ii -th bus route, the first bus arrives at time sis_i minutes, and each bus of this route comes did_i minutes later than the previous one.

As Serval's best friend, you wonder which bus route will he get on. If several buses arrive at the same time, you can print any of them.

输入格式

The first line contains two space-separated integers nn and tt ( 1n1001\leq n\leq 100 , 1t1051\leq t\leq 10^5 ) — the number of bus routes and the time Serval goes to the station.

Each of the next nn lines contains two space-separated integers sis_i and did_i ( 1si,di1051\leq s_i,d_i\leq 10^5 ) — the time when the first bus of this route arrives and the interval between two buses of this route.

输出格式

Print one number — what bus route Serval will use. If there are several possible answers, you can print any of them.

输入输出样例

  • 输入#1

    2 2
    6 4
    9 5
    

    输出#1

    1
    
  • 输入#2

    5 5
    3 3
    2 5
    5 6
    4 9
    6 1
    

    输出#2

    3
    
  • 输入#3

    3 7
    2 2
    2 3
    2 4
    

    输出#3

    1
    

说明/提示

In the first example, the first bus of the first route arrives at time 66 , and the first bus of the second route arrives at time 99 , so the first route is the answer.

In the second example, a bus of the third route arrives at time 55 , so it is the answer.

In the third example, buses of the first route come at times 22 , 44 , 66 , 88 , and so fourth, buses of the second route come at times 22 , 55 , 88 , and so fourth and buses of the third route come at times 22 , 66 , 1010 , and so on, so 11 and 22 are both acceptable answers while 33 is not.

首页