static Tree<int> GenerateTree() { Tree<int> tree = new Tree<int>(0); int n = int.Parse(Console.ReadLine()); for(int i = 0; i < n - 1; i++) { string line = Console.ReadLine(); int parentValue = int.Parse(line.Split(' ')[0]); int childValue = int.Parse(line.Split(' ')[1]); Tree<int> parent; Tree<int> child = new Tree<int>(childValue); if(i == 0) { parent = new Tree<int>(parentValue); tree = parent; } else { parent = tree.FindSubtree(parentValue); } parent.Children.Add(child); } return tree; }