Help me in solving PLAYPIAN problem

My issue

please see my code where is the issue

My code

#include <stdio.h>
int main() {
	int n;
	char str[100];
	printf("Enter number of test cases\n");
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
	    int flag=1;
	    gets(str);
	    int j=0;
	    while(str[i]!='\0')
	    {
	       if(((j%2)==0)&&(str[j]==str[j+1]))
	       {
	           flag=0;
	           break;
	       }
	        j++;
	    }
	    if(flag==1) printf("Yes\n");
	    else printf("No\n");
	}
	return 0;
}

Problem Link: PLAYPIAN Problem - CodeChef

@agnimitra40
dont print extra statement “enter number of test cases”.
and also for test cases.
1
AA
your output is “yes”.
but correct output is “no”.