I am solving this problem and I came up with this solution but it is saying input mismatch for taking value k as an integer.
Link to the problem [https://www.spoj.com/problems/NY10A/]
import java.util.Scanner;
public class main
{
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
int n=s.nextInt();
while(n-->0) {
int k=s.nextInt();
String t=s.nextLine();
int ttt=0,tth=0,tht=0,thh=0,htt=0,hth=0,hht=0,hhh=0;
for(int i=0;i<t.length()-2;i++) {
if(t.substring(i, i+2)== "TTT") {
ttt++;
}
else if(t.substring(i, i+2)== "TTH") {
tth++;
}
else if(t.substring(i, i+2)== "THT") {
tht++;
}
else if(t.substring(i, i+2)== "THH") {
thh++;
}
else if(t.substring(i, i+2)== "HTT") {
htt++;
}
else if(t.substring(i, i+2)== "HTH") {
hth++;
}
else if(t.substring(i, i+2)== "HHT") {
hht++;
}
else if(t.substring(i, i+2)== "HHH") {
hhh++;
}
}
System.out.println(k+ " " + ttt + " " + tth + " " + tht + " " + thh + " " + htt + " " + hth + " " + hht + " " + hhh);
}
}
}