the lead game ..why it is giving wrong answer..?

import java.io.*;
//import java.io.BufferedOutputStream;
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.io.PrintWriter;

class Main {
public static void main(String[] args) throws NumberFormatException, IOException {

BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); 	
PrintWriter pr=new PrintWriter(new BufferedOutputStream(System.out));	
int k=Integer.parseInt(bu.readLine());
int a[]=new int[k];
int b[]=new int[k];
int l;
for(l=0;l<=k-1;l++)
{
	String n=bu.readLine();
	String s[]=n.split(" ");
		
	a[l]=Integer.parseInt(s[0]);	
b[l]=Integer.parseInt(s[1]);
}

//int sum1=0,sum2=0;
int max1=a[0]-b[0],max2=b[0]-a[0];
for(l=0;l<k;l++)
{
if(a[l]>b[l])
{
	if( (a[l]-b[l]) > max1)
	{
	max1=a[l]-b[l];
	}	
	}		

if(b[l]>a[l])
{
	if( (b[l]-a[l]) > max2)
	{
	max2=b[l]-a[l];
	}	
	}		
}
		
if(max1 > max2)
{
	pr.print("1 "+ max1);	
}
	else if(max2>max1)
	{
		pr.print("2 "+ max2);	
	}

pr.close();
	}

}