#include<iostream>
#include <vector>
using namespace std;
const int alpha=26;

class trie {
	
private: 

	struct node{
		vector<node*> child;
		bool end;
		int countchild;
			  // initialization should be in the class/struct constructor	
	node () : child(alpha,nullptr), end(false), countchild(0) { }
	};

	node* root;  

	void show(node* n,  int inc) {
		cout<< string(inc, ' ')<<(n->end?"(END)":"()")<<" children:"<<n->countchild<<endl; 
		for (int i=0; i<alpha; i++) 
	    if (n->child[i]) {
	    	cout << string(inc, ' ') << (char)('a'+i)<<": "<<endl; 
	    	show (n->child[i], inc+2);
	    }
	}

public:  
    trie() {
    	root = new node; 
    }
    
	~trie() {
	//TODO rule of 3	
	}
	
	trie& operator= (trie) = delete;  //TODO rule of 3
	
	void insert(string key){
    	node* pcrawl=root;
    	for(auto c:key){
        	int index=tolower(c)-'a';
        	if (index<0 || index>=alpha)
        		continue;  
        	if(!pcrawl->child[index]){
            	pcrawl->child[index]=new node; 
        	}
        	pcrawl->countchild+=1;
        	pcrawl=pcrawl->child[index];
        
    	}
    	pcrawl->end=true;
	}

    void show() {
    	show(root,0); 
    }
}; 

int main() {
	trie t;
	t.insert ("tester");
	t.insert ("test");
	t.insert ("TERM");
	t.insert ("T.;0C"); 
    t.show(); 	
}