int k =1;voidinsert(char* w){int len =strlen(w);int p =0;for(int i =0; i < len; i++){int c = w[i]-'a';if(!trie[p][c]){
trie[p][c]= k;
k++;}
p = trie[p][c];}
f[p]=1;}intsur(char* w){int len =strlen(w);int p =0;for(int i =0; i < len; i++){int c = w[i]-'a';if(!trie[p][c]){return0;}
p = trie[p][c];}return f[p];}
constint maxn =2*1e6+9;int trie[maxn][26];int cntword[maxn];int fail[maxn];int cnt =0;voidinsertWords(string s){int root =0;for(int i =0; i < s.size(); i++){int next = s[i]-'a';if(!trie[root][next])
trie[root][next]=++cnt;
root = trie[root][next];}
cntword[root]++;//当前节点单词数+1}voidgetFail(){
queue <int>q;for(int i =0; i <26; i++){if(trie[0][i]){
fail[trie[0][i]]=0;
q.push(trie[0][i]);}}while(!q.empty()){int now = q.front();
q.pop();for(int i =0; i <26; i++){if(trie[now][i]){
fail[trie[now][i]]= trie[fail[now]][i];
q.push(trie[now][i]);}else
trie[now][i]= trie[fail[now]][i];}}}intquery(string s){int now =0, ans =0;for(int i =0; i < s.size(); i++){
now = trie[now][s[i]-'a'];for(int j = now; j && cntword[j]!=-1; j = fail[j]){
ans += cntword[j];
cntword[j]=-1;}}return ans;}
int k = 1;void insert(char* w){ int len = strlen(w); int p = 0; for (int i = 0; i < len; i++) { int c = w[i] - 'a'; if (!trie[p][c]) { trie[p][c] = k; k++; } p = trie[p][c]; } f[p] = 1;}int sur(char* w){ int len = strlen(w);