Doubt in--Treasure Hunt

I’m failing in 2 test cases out of 4.Pls help me pin-point error in my approach.
Link to my code is—https://ide.codingblocks.com/s/106217

you are not using appropriate combinatorics., wrong approach
what we do is for all nodes of the trie , we calculate number of strings in the substree and then just apply combinatorics such -
NC2(total nodes in the subtree of current nodes)-summation of NC2(children in each nodes)
unable to explain it that clearly ,
you can see my code