Dynamic Tree

You are given a tree containing N vertices. The vertices are numbered from 1 to N. A tree with N vertices is an undirected connected graph with exactly N−1 edges. Each vertex of the tree contains a lowercase English letter.

This is a companion discussion topic for the original entry at https://toph.co/p/dynamic-tree