#include #include const int mod=20071027; const int maxL=300000; int L,S,d[maxL+5],kase; char str[maxL+5],tmp[105]; const int maxnode=4000*105; const int sigma_size=26; struct Trie { int ch[maxnode][sigma_size]; bool val[maxnode]; int sz; Trie() { sz=1; } inline void clear() { sz=1; memset(ch,0,sizeof(ch)); memset(val,0,sizeof(val)); } inline void insert(char *s) { int u=0,n=strlen(s); for(int i=0;i=0;i--) for(int j=0,u=0;i+j