#P1706E. Qpwoeirut and Vertices
Qpwoeirut and Vertices
Description
You are given a connected undirected graph with vertices and edges. Vertices of the graph are numbered by integers from to and edges of the graph are numbered by integers from to .
Your task is to answer queries, each consisting of two integers and . The answer to each query is the smallest non-negative integer such that the following condition holds:
- For all pairs of integers such that , vertices and are reachable from one another using only the first edges (that is, edges ).
The first line contains a single integer () — the number of test cases.
The first line of each test case contains three integers , , and (, ) — the number of vertices, edges, and queries respectively.
Each of the next lines contains two integers and () — ends of the -th edge.
It is guaranteed that the graph is connected and there are no multiple edges or self-loops.
Each of the next lines contains two integers and () — descriptions of the queries.
It is guaranteed that that the sum of over all test cases does not exceed , the sum of over all test cases does not exceed , and the sum of over all test cases does not exceed .
For each test case, print integers — the answers to the queries.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains three integers , , and (, ) — the number of vertices, edges, and queries respectively.
Each of the next lines contains two integers and () — ends of the -th edge.
It is guaranteed that the graph is connected and there are no multiple edges or self-loops.
Each of the next lines contains two integers and () — descriptions of the queries.
It is guaranteed that that the sum of over all test cases does not exceed , the sum of over all test cases does not exceed , and the sum of over all test cases does not exceed .
Output
For each test case, print integers — the answers to the queries.
Note

In the first test case, the graph contains vertices and a single edge connecting vertices and .
In the first query, and . It is possible to reach any vertex from itself, so the answer to this query is .
In the second query, and . Vertices and are reachable from one another using only the first edge, through the path . It is impossible to reach vertex from vertex using only the first edges. So, the answer to this query is .

In the second test case, the graph contains vertices and edges.
In the first query, and . It is enough to use the first edges to satisfy the condition from the statement:
- Vertices and are reachable from one another through the path (edge ).
- Vertices and are reachable from one another through the path (edge ).
- Vertices and are reachable from one another through the path (edges and ).
- Vertices and are reachable from one another through the path (edges and ).
- Vertices and are reachable from one another through the path (edge ).
- Vertices and are reachable from one another through the path (edges , , and ).
If we use less than of the first edges, then the condition won't be satisfied. For example, it is impossible to reach vertex from vertex using only the first edges. So, the answer to this query is .
In the second query, and . Vertices and are reachable from one another through the path (edges , , and ). If we use any fewer of the first edges, nodes and will not be reachable from one another.