Information Transmission-2
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Problem Description
Information plays a very important role in
people's social life. For example, scientific research must not only obtain the
results of others 'research in time, but also publish and inform others of the
results of their own research in time. Only through this exchange of
information can we continue to develop. Network communication is based on
computer communication network for information transmission, exchange and
utilization.
There are n base points and there is a certain transfer relationship between them., the
information can be transmitted from point A to point B, and point B to point C,
and so on. Now there is a massage to be broadcasted
, at least which base points to be sent
the message first, so that all the base points can be received?
Input Format
The first line of the input
contains one integer T, which is the number of test cases (1<=T<=8). Each test case specify:
* Line 1: n (2 ≤ n ≤ 100)
*Line 2~n+1: each line contains a 01 string of length n .
ie:if the sixth column in the third row is 1, it
means that the third base point can pass the message to the sixth base point.
Output Format
For each test case generate a
single line: minimum number of base that the massage must be sent first, so that all the
basis points can be received.
2
3
010
001
000
6
010000
001001
000100
010000
001000
0000001
2