#include"cstdio" #include"queue" #include"cmath" #include"stack" #include"iostream" #include"algorithm" #include"cstring" #include"queue" #include"map" #include"set" #include"vector" #define LL long long #define ull unsigned long long #define mems(a,b) memset(a,b,sizeof(a)) #define ls pos<<1 #define rs pos<<1|1 #define max(a,b) (a)>(b)?(a):(b) using namespace std; const int N = 1e6+5; const int MOD = 10061; const int INF = 0x1fffff; struct node{ int cnt; int son[26]; void init(){ for(int i=0;i<26;i++) son[i]=0; cnt=0; } }tree[N<<2]; int tot,root; char s[N],op[10]; int newnode(){ tree[++tot].init(); return tot; } void Insert(char *s,int len){ int now=root; for(int i=0;i