Help me in solving STJ11 problem

Problem Link: CodeChef: Practical coding for everyone
Learning course: Solve Programming problems using Java

My code

import java.util.Scanner;
class Codechef
{
	public static void main (String[] args)
	{
		Scanner read = new Scanner(System.in);
		
		int t = read.nextInt();
		for(int i=0; i<t; i++)
		{
    		String a = read.next();
    		// Update your code below to solve this problem
    		for(int j=0;j<n;j++){
    		    
    		}


		}
	}
}

My issue