Why am i getting wa for Harrenhal??

My code : `#include
#include<string.h>
#include<stdio.h>

using namespace std;

void run()
{

char x[100002];
gets(x);
int i,l=strlen(x);
bool flag=true;

for (i=0;i<=l/2-1;i++)
{
if (x[i]!=x[l-i-1]) {flag=false;break;}
}
if (flag) cout<<1;
else cout<<2;
cout<<’\n’;
}

int main()
{
ios_base::sync_with_stdio(false);

char t;
cin>>t;
while(t!='0')
{
    run();
    t--;
}
return 0;

}
`

Seems to be similar to other submissions but i am getting WA in subtask 1 but AC in subtask 2 pls help?