https://lucienshui.github.io/blog/posts/codeforces_1098c_constructatree/
Codeforces - 1098C - Construct a tree - Lucien's Blog