#T368. 找树根和孩子
找树根和孩子
Description
Given a tree, output the root of the tree root, the node with the most children max, and its children.
Input Format
First line: n (number of nodes ≤ 100), m (number of edges ≤ 200).
The following m lines: each line contains two nodes x and y, indicating that y is a child of x (x, y ≤ 1000).
Output Format
First line: The root of the tree: root;
Second line: The node with the most children: max;
Third line: The children of max (sorted in ascending order by their numbers).
8 7
4 1
4 2
1 3
1 5
2 6
2 7
2 8
4
2
6 7 8
Hint
If there are multiple maximum values, select the one with the smallest index.