#include #include #include #include #include using namespace std; struct node{ node *ch[26]; int tag,cnt; node(){ memset(ch,0,sizeof(ch)); tag=cnt=0; } }; node *root; void pushdown(node* &pt){ if(pt->tag){ pt->tag=0; for(int i=0;i<26;i++){ if(pt->ch[i]){ pt->ch[i]->cnt=0; pt->ch[i]->tag=1; } } } } void insert(node* &pt,char *s){ if(pt==NULL) pt=new node; pt->cnt++; if(s[0]==0) return; pushdown(pt); insert(pt->ch[s[0]-'a'],s+1); } int serch(node* &pt,char *s){ if(pt==NULL) return -1; if(s[0]==0) return pt->cnt; pushdown(pt); serch(pt->ch[s[0]-'a'],s+1); } void del(node* &pt,char *s,int val){ pt->cnt-=val; if(s[0]==0){ pt->tag=1; return; } pushdown(pt); del(pt->ch[s[0]-'a'],s+1,val); } char s[35]; int main(){ int n; scanf("%d",&n); while(n--){ scanf("%s",s); if(s[0]=='i'){ scanf("%s",s); insert(root,s); } else if(s[0]=='s'){ scanf("%s",s); int tmp=serch(root,s); if(tmp>0) puts("Yes"); else puts("No"); } else if(s[0]=='d'){ scanf("%s",s); int tmp=serch(root,s); if(tmp!=-1){ del(root,s,tmp); } } } }