#include<bits/stdc++.h>
using namespace std;
int main(){
int a[10],b[10],c[10],maxx=0;
for(int i=1;i<=7;i++){
cin>>a[i]>>b[i];
c[i]=a[i]+b[i];
}
for(int i=1;i<=7;i++){
if(c[i]>maxx){
maxx=c[i];
}
}
for(int i=1;i<=7;i++){
if(c[i]==maxx&&c[i]>8){
cout<<i;
return 0;
}
else{
cout<<0;
return 0;
}
}
return 0;
}