int t;
scanf("%d",&t);
int i;
for(i=0;i<t;i++)
{ int n;
scanf("%d",&n);
char str[n+1];
char str1[n+1];
scanf("%s",str);
int l=0,j=0;
while(l<n)
{
if(str[l]=='H')
{
str1[j]='H';
j++;
}
else if(str[l]=='T')
{
str1[j]='T';
j++;
}
l++;
}
int ll,jj;
ll=strlen(str1);
printf("%d\n",ll);
printf("%s\t",str1);
printf("\n");
int counter=0;
if(str1[0]=='T')
{
printf("INVALID\n");
}
else if(str[0]!='T')
{
for(jj=0;jj<ll-1;jj++)
{
if(str1[jj]=='H'&&str1[jj+1]=='H')
{
counter++;
}
else if(str1[jj]=='T'&&str1[jj+1]=='T')
{
counter++;
}
}
if(counter>0)
printf("INVALID\n");
else
printf("VALID\n");
}
}
}
.
