#K74992. Taco Subordinates
Taco Subordinates
Taco Subordinates
This problem involves finding all direct and indirect subordinate employees in a company hierarchy. You are given an integer e representing an employee's identifier and a list of ordered pairs that represent the direct supervisor-subordinate relationships in the company. The goal is to output a sorted list of all subordinates (both direct and indirect) for the employee e.
In mathematical terms, if we denote the set of direct subordinates of an employee \( e \) as \( S(e) \), then you are required to find the set \[ T(e) = \bigcup_{k \ge 1} S^k(e), \] where \( S^k(e) \) represents the subordinates at a distance of k in the hierarchy.
You should read the input from standard input and print the result to standard output.
inputFormat
The input is read from standard input (stdin) and is formatted as follows:
- The first line contains an integer e which is the employee identifier for which you need to find all subordinates.
- The second line contains an integer m representing the number of supervisor-subordinate relationships.
- The following m lines each contain two integers a and b, denoting that employee a is the direct supervisor of employee b.
outputFormat
Output a single line to standard output (stdout) containing the sorted list of subordinate employee identifiers separated by a space. If the employee has no subordinates, output an empty line.
## sample1
4
1 2
1 3
2 4
2 5
2 3 4 5
</p>