Strong Connected Components
A computer network comprises n computers, numbered from 0 to n - 1. Each one, after receiving a message, passes it to some other computers. If a message from computer x can reach a computer y, this does not necessarily mean that a message from computer y reaches the computer x. The system administrators want to determine the minimum number of computers from which a message has to be sent in order to reach all the computers in the network.
For better transmission of messages, they believe that the network needs to be extended by adding new connections between some computers, so when sending a message from an arbitrary computer it will be distributed to all others. For this purpose, it is necessary to determine the minimum number of new connections to be added, so that each of the computers can be used as initial for distribution of messages.
Write a program cnet that finds the minimal number of computers from which a message needs to be sent in order to be distributed to all computers in the network and finds the minimum number of new connections that need to be added, in order to allow a message, sent from each of the computers, to reach every other computer in the network.
The first line contains two integers n (1 ≤ n ≤ 1600) and m (0 ≤ m ≤ 120000), representing the number of computers and the number of connections between them. Each of the next m lines describe one available connection. The first number is the number of the computer sending the message, and the second number is the number of the computer receiving the message.
On a single line print two integers - the minimum number of computers that are used as initial for distributing a message to the whole network and the minimum number of additional connections needed to extend the network in a way that a message sent from an arbitrary chosen computer, will reach all the others.
5 6 0 1 0 3 0 2 1 3 1 4 4 0
6 12 0 1 0 2 1 0 1 2 2 0 2 1 3 4 3 5 4 3 4 5 5 3 5 4