Neighborhoods in Graphs

No attempts yetTime limit1sMemory limit256 MB

Problem

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.

Input

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)

Output

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.