Model co-conspirators as an undirected graph: each vertex is a super-villain, and each edge joins two villains who plotted together. For a given vertex vx, count how many other vertices lie within distance 1 or 2. Do not count vx itself.
The first line contains T, the number of test cases. Each test case is one line with n, e, then 2e vertex names describing edges, and finally the query vertex vx. (n < 100, e < 1000)
For each test case, print The number of supervillains in 2-hop neighborhood of vx is C, where C is the size of the 2-hop neighborhood.