Help me in solving PREQ45 problem

My issue

answer

My code

# Update the code below to solve the problem

t = int(input())
for i in range(t):
    X = int(input())
    S = input()
    

Learning course: Design and Analysis of Algorithms
Problem Link: https://www.codechef.com/learn/course/kl-daa/KLDAA24PRE06/problems/PREQ45

help me to sloving the problem