why getting wrong answer in the lead game

#include<stdio.h>
int main()
{ int n,i,si,ti,w,m=0,l;
scanf("%d",&n);

for(i=1;i<=n;i++)
   {  scanf("%d %d",&si,&ti);
       
	   if(si>ti)
      { l=si-ti;
       if(l>m)

{m=l;
w=1;}

		}
		else{
			l=ti-si;
			if(l>m)
			{m=l;
			w=2;
		}
		}	
	}
	printf("%d %d",w,m);
	return 0;
}
//