Comments

As a contestant, problem D is the one of the best problems I have solved in my entire life. And BTW I was running from school to home 14 years ago ;)

I was looking forward to reaching the specialist rank today, but unfortunately the contest started and I couldn't participate because Codeforces kept saying 'starts in 10 minutes'. gg :(

as a tester, I agree with the comment parent[parent[parent[parent[above]]]]