#include #include using namespace std; string s,ss; int StorePalin[1005][1005]={0}; void init(int strLen) { for(int i=1;i=0 && y=0 && y>n>>q; cin>>ss; while(q--) { int strLength; long long count[1005]={0}; long long modValue = 1000000007; int ii,jj; cin>>ii>>ii>>jj; string d; for(int i=ii;i<=jj;i++) d+=ss; s=d; strLength = s.length(); init(strLength); count[strLength-1]=count[strLength]=1; for(int i=strLength-2;i>=0;i--){ long sum=count[i+1]; for(int j=i+1;j<=strLength-1;j++) { if(StorePalin[i][j]==1){ sum = (sum + count[j+1])%modValue; } } count[i]=sum; } cout<