I quite dont understand the question, can you explain the sample test case. And is their use of Master parent.
Beautiful vertices
@coolio.boy385 Not able to pass the sample test case
Please refer this. I have explained the sample test case here.
In san=mple test case, 1 has 0 parent and 1 chidren, also 2 has 1 parent and 2 children, so shouldn’t ans be 2?