Codeforces 966E. May Holidays(虚树、分块)

NoSuchKey