시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 2 | 2 | 2 | 100.000% |
The Dean of the Unseen University, not unknown to inhabitants of the Discworld or their acquaintances, has decided to modernise his communication by installing a computer network consisting of a number of bidirectionally connected hosts, numbered from 1 to h consecutively. Unfortunately, due to the highly magical nature of the environment, random changes in the network structure occur quite often.
Therefore, it is especially useful to know which hosts can be reached and which cannot. Luckily the changes in the structure can be monitored without further affecting the network and the current network state can therefore be known at any time.
It is agreed upon that any host which can be reached in 10 hops or less from the main host, number 1, is called online. This means that there may be a number of hosts which are reachable from host 1, but are not called online. The Dean wants to know how many such hosts there are.
The first line of the input file contains a single number: the number of test cases to follow. Each test case has the following format:
Duo to the magical environment, the only condition that applies to p, q, r and s is that they are in the range 1...h.
For every test case in the input file, the output should contain a single number, on a single line: the number of hosts reachable from host number 1 which are not considered online.
2 4 4 1 2 2 3 3 4 4 1 4 1 3 1 3 2 3 3 4 12 5 10 11 3 6 9 8 1 4 4 7 8 11 3 5 6 7 10 6 5 5 9 8 2 5 6 2 12
0 1