atcoder#ABC264E. [ABC264E] Blackout 2

[ABC264E] Blackout 2

Score : 500500 points

Problem Statement

A country has NN cities and MM power plants, which we collectively call places. The places are numbered 1,2,,N+M1,2,\dots,N+M, among which Places 1,2,,N1,2,\dots,N are the cities and Places N+1,N+2,,N+MN+1,N+2,\dots,N+M are the power plants.

This country has EE power lines. Power Line ii (1iE1 \le i \le E) connects Place UiU_i and Place ViV_i bidirectionally. A city is said to be electrified if one can reach at least one of the power plants from the city using some power lines.

Now, QQ events will happen. In the ii-th (1iQ1 \le i \le Q) event, Power Line XiX_i breaks, making it unusable. Once a power line breaks, it remains broken in the succeeding events.

Find the number of electrified cities right after each events.

Constraints

  • All values in input are integers.
  • 1N,M1 \le N,M
  • N+M2×105N+M \le 2 \times 10^5
  • 1QE5×1051 \le Q \le E \le 5 \times 10^5
  • 1Ui<ViN+M1 \le U_i < V_i \le N+M
  • If iji \neq j, then UiUjU_i \neq U_j or ViVjV_i \neq V_j.
  • 1XiE1 \le X_i \le E
  • XiX_i are distinct.

Input

Input is given from Standard Input in the following format:

NN MM EE

U1U_1 V1V_1

U2U_2 V2V_2

\vdots

UEU_E VEV_E

QQ

X1X_1

X2X_2

\vdots

XQX_Q

Output

Print QQ lines. The ii-th line should contain the number of electrified cities right after the ii-th event.

5 5 10
2 3
4 10
5 10
6 9
2 9
4 8
1 7
3 6
8 10
1 8
6
3
5
8
10
2
7
4
4
2
2
2
1

Initially, all cities are electrified.

  • The 11-st event breaks Power Line 33 that connects Point 55 and Point 1010.- Now City 55 is no longer electrified, while 44 cities remain electrified.
  • The 22-nd event breaks Power Line 55 that connects Point 22 and Point 99.
  • The 33-rd event breaks Power Line 88 that connects Point 33 and Point 66.- Now Cities 22 and 33 are no longer electrified, while 22 cities remain electrified.
  • The 44-th event breaks Power Line 1010 that connects Point 11 and Point 88.
  • The 55-th event breaks Power Line 22 that connects Point 44 and Point 1010.
  • The 66-th event breaks Power Line 77 that connects Point 11 and Point 77.- Now City 11 is no longer electrified, while 11 city remains electrified.