struct node{
map<char,node*> edges;
int end;
node(){
this->edges = map<char,node*>();
this->end = 0;
}
};
void insert(string& s, node* n, int l=0){
if(l==s.length())
n->end++;
else{
if(n->edges.count(s[l])==0){
node* p = new node;
n->edges[s[l]]=p;
}
insert(s,n->edges[s[l]],l+1);
}
}
int find(string& s, node* n, int l=0){
if(l==s.length()) return n->end;
if(n->edges.count(s[l])){
return find(s,n->edges[s[l]],l+1);
}else return 0;
}
bool Delete(string& s, node* n, int l=0){
if(l==s.length()){
n->end--;
if(n->edges.size() || n->end){
return false;
}else return true;
}else {
if(n->edges.count(s[l])==0) return false;
bool del=Delete(s, n->edges[s[l]], l + 1);
if(del){
node* p=n->edges[s[l]];
n->edges.erase(s[l]);
delete p;
}
if(n->edges.size() || n->end) return false; else return del;
}
}