Help me in solving BALL_GAME problem

My issue

explain in detail

My code

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	Scanner sc =new Scanner(System.in);
    int n=sc.nextInt();
    while(n-->0){
        int x=sc.nextInt();
        for(int i=0;i>x;i++){
            for(int j=0;j>x;j++)
            if()
        }
        int y=sc.nextInt();
        int z=sc.nextInt();
    }
	}
}

Problem Link: Ball Game Practice Coding Problem