Help me in solving S03E02 problem

My issue

I don’t know how to solve this problam

My code

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

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner obj = new Scanner(System.in);
		int T = obj.nectInt();
		for(int i = 0;i < T;i++){
		    int N = obj.nextInt();
		    int K = obj.nextInt();
		    String S = obj.nextLine();
		    
		}

	}
}

Problem Link: The One Where No One is Ready Practice Coding Problem - CodeChef