C. Tree Pruning
time limit per test: 3 seconds
memory limit per test: 256 megabytes
t+pazolite, ginkiha, Hommarju - Paved Garden
You are given a tree with n nodes, rooted at node 1. In this problem, a leaf is a non-root node with degree 1.
In one operation, you can remove a leaf and the edge adjacent to it (possibly, new leaves appear). What is the minimum number of operations that you have to perform to get a tree, also rooted at node 1, where all the leaves are at the same distance from the root?
Input
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤10^4). The description of the test cases follow