We say tree T1 is a top-bottom subtree of tree T if
1. T1 is a tree and its nodes and edges are respectively the subsets of T’s nodes and edges, and
2. w is node of tree T1 but not the root of T, then w’s parent is also in tree T1.
We say two rooted unordered trees are isomorphic if
1. a tree with a single node (the root) is only isomorphic to a tree with a single node;
2. two trees with roots A and B, none of which is a single-node tree, are isomorphic iff there is a 1-1 correspondence between the subtrees of A and the subtrees of B such that corresponding subtrees are isomorphic.
Given two rooted unordered trees, your task is to find out their top-bottom subtrees respectively which are isomorphic, and maximize the number of nodes of the subtrees, i.e., the Greatest Common Subtree.