You are given a directed network of flights i.e. N cities and M one-directional flights. Each city has a particular air quality index value associated with it. Now, your task is to determine the maximum threshold value X such that if the flights incident to or from the cities with air quality index values less than X is canceled then there should exist a reachable component of cities in the network of size at least K. A subcomponent of a flight network is considered to be a reachable component if all the cities in that component are connected, this implies that all the flights are reachable from each other via direct or connecting flights.
Note: You can assume that the answer always exists.
Input format
Output format
Print the maximum threshold value as described in the problem statement.
Constraints
1≤K≤N≤105
1≤M≤106
1≤valueofnodes≤109
If you keep the threshold as 32 then you see that there exists a component of size 5 which is greater than 3 and follows the given property.