Given a simple undirected connected graph with $n$ vertices and $m$ edges.
There are $q$ queries. Each query provides two distinct vertices $x$ and $y$. You can start at $x$ and walk along the graph until you reach $y$, with the restriction that you are not allowed to visit $x$ or $y$ except at the start and the end. Find the number of vertices $z$ such that there exists a walk that passes through $z$, including $x$ and $y$. Note that the path does not have to be a simple path; the only restriction is that you cannot visit $x$ and $y$ again after the start and before the end, respectively.
Input
The first line contains a positive integer $T$, representing the number of test cases. The format for each test case is as follows:
- The first line contains two positive integers $n$ and $m$, representing the number of vertices and edges.
- The next $m$ lines each contain two positive integers $x$ and $y$, representing an edge between $x$ and $y$.
- The next line contains a positive integer $q$, representing the number of queries.
- The next $q$ lines each contain two positive integers $x$ and $y$, representing a query.
Output
For each query, output a single positive integer on a new line, representing the number of reachable vertices.
Examples
Input 1
1 5 5 1 2 1 3 2 4 4 5 2 5 5 1 2 1 4 2 3 2 5 3 5
Output 1
2 4 3 3 5
Examples 2~5
See ex_*.in/ex_*.out in the provided files, which correspond to subtasks 2 through 5, respectively.
Constraints
This problem uses bundled testing; you must pass all test cases in a subtask to receive points for that subtask.
For all data, $1\le T\le 1000, 1\le \sum n\le 2\times 10^5, 1\le \sum m \le 5\times 10^5, 1\le \sum q\le 5\times 10^5$.
| Subtask ID | Special Properties | Score |
|---|---|---|
| $1$ | $1\le T\le 5,n,m,q\le 20$ | $10$ |
| $2$ | $\sum n\le 1000,\sum m,\sum q\le 2000$ | $20$ |
| $3$ | $m=n-1$ | $20$ |
| $4$ | The graph remains connected after removing any single vertex | $10$ |
| $5$ | No special properties | $40$ |