var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var NTHL=(Arr.shift()).split(" ").map(Number);
var N=NTHL[0];
var T=NTHL[1];
var H=NTHL[2];
var L=NTHL[3];
var th=[];
for(var i=0;i<N;i++){
   var arr=Arr[i].split(" ").map(Number);
   th.push(arr);
}
var sum=0;
while(true){
   for(var i=0;i<N;i++){
      if(th[i][0]==0 && th[i][1]==0)return console.log(i+1);
      if(th[i][0]==0){sum+=100;th[i][1]--;}
      else{sum+=10;T++;th[i][0]--}
      if(sum>=90){
         var ch=sum-90;
         if(T*10<ch)return console.log(i+1);
         th[i][0]+=(ch/10);
         sum=0;
      }
   if(T>L)return console.log(i+1);
   }
}