

Note that the structure of the tree must be maintained while serialization and deserialization. Also, you can use any method to serialize or deserialize the tree. You just need to see that the tree can be serialized into a string and further deserialized into the original tree.
The first line contains an integer 'T' which denotes the number of test cases or queries to be run. Then the test cases are as follows.
The first line of each test case contains elements of the N-ary tree in the level order form. The line consists of values of nodes separated by a single space. In case a node is changed, we take -1. To get the next node
The first not-null node(of the previous level) is treated as the parent of the first nodes of the current level. The second not-null node (of the previous level) is treated as the parent node for the next nodes of the current level and so on.
The input ends when all nodes at the last level are null(-1).
The above format was just to provide clarity on how the input is formed for a given tree.
The sequence will be put together in a single line separated by a single space. Hence, for the below-depicted tree, the input will be given as:
1 -1 2 3 4 -1 5 6 -1 -1 -1 -1 -1

For each test case, you need to print the deserialized tree after its serialization.
Print the output of each test case in a separate line.
You don’t need to print anything; It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^4
Time limit: 1 sec
We will maintain a queue that will store tree nodes. For every node, we will push its child node’s value in the vector and push its child nodes in the queue so that they can be explored further. After pushing all the child node’s value, we will push ‘-1’ to the vector. We will continuously explore all the nodes until the queue is not empty.
Algorithm
For deserialization, we have to convert the values in the vector ‘FILE’ to an N-ary tree. We will take a queue as we have maintained in serialization and initially push a node with data equal to FILE[ 0 ]. As we have appended ‘-1’ after child nodes of every node. So all the nodes before ‘-1’ will become child nodes of the node at the front of the queue.
So we will create nodes until ‘-1’ is encountered. All these nodes will be the child of the node at front of the queue and we will push all these nodes to ‘Q’ so that we can get the child nodes of these nodes also.