I didn’t want to ask during the contest, but I felt like my solution was correct, yet still got WA. I haven’t seen an editorial for the problem yet so I have no way to verify my solution.

So I’d like to ask for a test case that my method fails.

**My Approach**

I picked a root node in the tree (Usually 1, but I tried others) and calculated the distance to each node from there, using Breath First Search/Dijkstra.

I then grouped the nodes into 4 groups with each node going into the group number dist_from_root%4

If group(0) + group(2) == group(1) + group(3), Then the answer is 1 and the sets are chosen in the same way

If they not equal I moved only nodes from one of the groups across to the other side until they were equal, but making the answer 2.

**Solution Code**

https://www.codechef.com/viewsolution/22349636

Please help me find a failed test case, I’ve tried to find my error but could not.