what is generic tree and how we gonna take input
Generic tree input
A generic tree is a tree where any node can have any number of children (unlike binary trees where a node can have atmost 2 children).
The first integer in each row indicates the data at the node whereas the second integer indicates the no of children that node has .
As for the sample testcase given in the problem
1 2
2 2
3 0
4 0
5 2
6 0
7 0
2
Here the tree looks like
1 Level 0
/ \
2 5 Level 1
/ \ / \
3 4 6 7 Level 2