#abc304e. [abc304_e]Good Graph

[abc304_e]Good Graph

Problem Statement

You are given an undirected graph GG with NN vertices and MM edges. For i=1,2,ldots,Mi = 1, 2, \\ldots, M, the ii-th edge is an undirected edge connecting vertices uiu_i and viv_i.

A graph with NN vertices is called good if the following condition holds for all i=1,2,ldots,Ki = 1, 2, \\ldots, K:

  • there is no path connecting vertices xix_i and yiy_i in GG.

The given graph GG is good.

You are given QQ independent questions. Answer all of them. For i=1,2,ldots,Qi = 1, 2, \\ldots, Q, the ii-th question is as follows.

  • Is the graph G(i)G^{(i)} obtained by adding an undirected edge connecting vertices pip_i and qiq_i to the given graph GG good?

Constraints

  • 2leqNleq2times1052 \\leq N \\leq 2 \\times 10^5
  • 0leqMleq2times1050 \\leq M \\leq 2 \\times10^5
  • 1lequi,vileqN1 \\leq u_i, v_i \\leq N
  • 1leqKleq2times1051 \\leq K \\leq 2 \\times 10^5
  • 1leqxi,yileqN1 \\leq x_i, y_i \\leq N
  • xineqyix_i \\neq y_i
  • $i \\neq j \\implies \\lbrace x_i, y_i \\rbrace \\neq \\lbrace x_j, y_j \\rbrace$
  • For all i=1,2,ldots,Ki = 1, 2, \\ldots, K, there is no path connecting vertices xix_i and yiy_i.
  • 1leqQleq2times1051 \\leq Q \\leq 2 \\times 10^5
  • 1leqpi,qileqN1 \\leq p_i, q_i \\leq N
  • pineqqip_i \\neq q_i
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN MM u1u_1 v1v_1 u2u_2 v2v_2 vdots\\vdots uMu_M vMv_M KK x1x_1 y1y_1 x2x_2 y2y_2 vdots\\vdots xKx_K yKy_K QQ p1p_1 q1q_1 p2p_2 q2q_2 vdots\\vdots pQp_Q qQq_Q

Output

Print QQ lines. For i=1,2,ldots,Qi = 1, 2, \\ldots, Q, the ii-th line should contain the answer to the ii-th question: Yes if the graph G(i)G^{(i)} is good, and No otherwise.


Sample Input 1

6 6
1 2
2 3
2 3
3 1
5 4
5 5
3
1 5
2 6
4 3
4
2 5
2 6
5 6
5 4

Sample Output 1

No
No
Yes
Yes
  • For the first question, the graph G(1)G^{(1)} is not good because it has a path 1rightarrow2rightarrow51 \\rightarrow 2 \\rightarrow 5 connecting vertices x1=1x_1 = 1 and y1=5y_1 = 5. Therefore, print No.
  • For the second question, the graph G(2)G^{(2)} is not good because it has a path 2rightarrow62 \\rightarrow 6 connecting vertices x2=2x_2 = 2 and y2=6y_2 = 6. Therefore, print No.
  • For the third question, the graph G(3)G^{(3)} is good. Therefore, print Yes.
  • For the fourth question, the graph G(4)G^{(4)} is good. Therefore, print Yes.

As seen in this sample input, note that the given graph GG may have self-loops or multi-edges.