TLE in SPAMCLAS , PLEASE HELP!

import java.util.*;
class SPAMCLAS1
{
public static void main(String args[])
{
Scanner scan=new Scanner(System.in);
int t=scan.nextInt();
for(int i=0;i<t;i++)
{

		int n=scan.nextInt();
		int minx=scan.nextInt();
		int maxx=scan.nextInt();
		int[] a=new int[n];
		int[] b=new int[n];
		
		for(int j=0;j<n;j++)
		{
			a[j]=scan.nextInt();
			b[j]=scan.nextInt();
		}
		int counter=minx,even=0,odd=0,f=counter;
		boolean e,E=true;
		if(minx%2==0){e=true;}
		else{e=false;}
		//System.out.println(maxx);
		long startTime = System.nanoTime();

		
		
		while(f<=maxx)
		{
			for(int j=0;j<n;j++)
			{
				if(a[j]%2==0&&b[j]%2==0){e=true;}
				
				else
				{
					if(e==false)
					{
						if(a[j]%2!=0&&b[j]%2!=0)
						{
							e=true;
						}
						else{e=false;}
					}
					else
					{
						if(b[j]%2==0)
						{
							e=true;
						}
						else{e=false;}
					}
				}
				//if(e){E=true;}
				//else{E=false;}
			}
			if(e){even++;}
			else{odd++;}
			//System.out.print(f);

			f=++counter;
			if(f%2==0){e=true;}
			else{e=false;}
			//System.out.println("  "+f);
		}	
		System.out.println(even+" "+odd);
		long endTime   = System.nanoTime();
		long totalTime = endTime - startTime;
		System.out.println((float)totalTime/1000000000);
	}
	
}

}