401876: GYM100551 B GraphAero

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. GraphAerotime limit per test2 secondsmemory limit per test256 megabytesinputbridges.inoutputbridges.out

Given an undirected graph with N vertices's and M edges. You are to process K queries of adding new edges into the graph. After each query you should output the only number - amount of bridges in graph. Graph may contain loops and multiple edges.

Input

The first line of input contains two integers N and M: the number of vertices and edges, respectively. 1 ≤ N ≤ 105, 1 ≤ M ≤ 105. The following M lines contain edges, one per line. Two integers ai and bi follow, describing the edge. 1 ≤ ai, bi ≤ N.

The next line of input contains only integer K: the number of requests. 1 ≤ K ≤ 105. The following K lines contain requests, one per line. Two integers ai and bi follow, describing the edge to add. 1 ≤ ai, bi ≤ N.

Output

Write K integers: the number of bridges in the graph after each request.

ExamplesInput
4 0
4
1 2
2 3
3 4
1 4
Output
1
2
3
0

加入题单

算法标签: