
#include<iostream>
using namespace std;
int main(){
  int N,T,L;
  int r;
  int i;
  cin>>N>>T>>L>>L;
  int m[101],n[101];
  for(i=0;i<N;i++)cin>>m[i]>>n[i];
  i=r=0;
  while(1){
    if(m[i]+n[i]==0)break;
    bool broken=false;
    if(m[i]){
      m[i]--;
      r+=10;
      T++;
    }else{
      n[i]--;
      r+=100;
    }
    if(T>L)broken=true;
    if(r>=90){
      r-=90;
      if(r/10 > T){
        broken=true;
      }else{
        m[i]+=r;
        T-=r/10;
        r=0;
      }
    }
    if(broken)break;
    i = (i+1)%N;
  }
  cout<<i+1<<"\n";
}