Hi everyone, I get stuck with this problem.
Give an undirected graph with n (n <= 2.10^3) vertices and m (m <= 3.10^4) edges. There are q (q <= 10^4) queries.
You have to answer each query L, R : How many connected components if we remove edges from index L to index R
The first line contains 2 integer numbers n and m.
Next m lines contain the edges of this graph, each line contains 2 integer number u and v representing one edge.
The next line contains a single integer q : the number of queries
Next q lines contain 2 integer L and R
Example
Input:
6 5
1 2
5 4
2 3
3 1
3 6
6
1 3
2 5
1 5
5 5
2 4
3 3
Output
4
5
6
3
4
2
Thank!