Problem http://www.codechef.com/problems/RRECIPE

,

I am not getting where I went wrong…this code seems pretty correct but when I submitted it gave wrong ans.

#include<stdio.h>
#include<string.h>
unsigned long int M=10000009;
char str[1000001]={'\0'};
int main()
{
int i,j,limit,t,flag;
unsigned long int ans=1;
scanf("%d",&t);
while(t!=0)
{
flag=0;
scanf("%s",&str);
limit=strlen(str);
for(i=0,j=limit-1;i<=j;i++,j--)
{
if(str[i]!=str[j])
{
if(str[i]!='?' && str[j]!='?')
{
printf("0\n");
flag=1;
break;
}
}
else
{
if(str[i]=='?')
ans=(ans*26)%M;
}
}
if(flag==0)
{
printf("%lld\n",ans);
}
t--;
ans=1;
}
return 0;
} 

any suggestions???

Try printf("%ld\n",ans). You are printing a long int, not a long long int.