USACO 2022 December Contest, Problem 1 Barn Tree

Hi, I am working on this problem:

The grading server is marking only 1 and 3 correctly, however, I validated cases 2 and 8 (as a sample), and both have the correct output. My output has a different sequence of lines compared to the provided output but each entry matches exactly. Even the ones that the grading server marked correct, my sequencing is different than the provided file. What could be causing the grading server to mark the answers incorrect?

Any guidance would be greatly appreciated.

What do you mean by having a different sequence of lines?