#P17223. [ICPC 2017 Nanning R] The Maximum Unreachable Node Set
[ICPC 2017 Nanning R] The Maximum Unreachable Node Set
Problem Description
In this problem, we would like to talk about unreachable sets of a directed acyclic graph . In mathematics a directed acyclic graph is a directed graph with no directed cycles. That is a graph such that there is no way to start at any node and follow a consistently-directed sequence of edges in that eventually loops back to the beginning again.
A node set denoted by containing several nodes is known as an unreachable node set of if, for each two different nodes and in , there is no way to start at and follow a consistently-directed sequence of edges in that finally archives the node . You are asked in this problem to calculate the size of the maximum unreachable node set of a given graph .
Input Format
The input contains several test cases and the first line contains an integer which is the number of test cases.
For each case, the first line contains two integers and indicating the number of nodes and the number of edges in the graph . Each of the following lines describes a directed edge with two integers and and indicating an edge from the -th node to the -th node. All edges provided in this case are distinct.
We guarantee that all directed graphs given in input are DAGs and the sum of in input is smaller than .
Output Format
For each test case, output an integer in a line which is the size of the maximum unreachable node set of .
3
4 4
1 2
1 3
2 4
3 4
4 3
1 2
2 3
3 4
6 5
1 2
4 2
6 2
2 3
2 5
2
1
3