Given pairs of nodes in a forest, you are asked to find their common ancestors.
Here is a reference solution of the problem.