#P3854. [TJOI2008] 通讯网破坏

[TJOI2008] 通讯网破坏

Description

The leaders of country AA have proposed many strategies. As the chief computer scientist of country AA, your task is to write a program to determine whether each strategy is feasible.

Input Format

The first line contains two integers NN and MM, representing the number of cities in country BB and the number of pairs of cities that can communicate directly. The next MM lines each contain two integers CiC_i and DiD_i, 1Ci,DiN1\leq C_i,D_i \leq N and CiDiC_i \neq D_i, indicating that cities CiC_i and DiD_i can communicate directly. It is guaranteed that each pair (Ci,Di)(C_i,D_i) appears at most once.

The next line contains an integer QQ, representing the number of strategies proposed by the leaders of country AA. The next QQ lines each contain three integers Si,Ti,MiS_i, T_i, M_i (1Si,Ti,MiN1 \leq S_i,T_i,M_i\leq N, and Mi,Si,TiM_i, S_i, T_i are pairwise distinct), indicating that this strategy attempts to sever communication between SiS_i and TiT_i by destroying MiM_i.

Output Format

Output QQ lines, each indicating whether the corresponding strategy is feasible. If, after destroying MiM_i, SiS_i and TiT_i cannot communicate, then the strategy is feasible and you should output yes\mathtt{yes} on the ii-th line; otherwise, output no\mathtt{no}.

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

yes
no
no

Hint

For 30%30\% of the testdata, 1N100,1Q1001 \leq N \leq 100,1 \leq Q \leq 100.

For 100%100\% of the testdata, $1 \leq N \leq 20000,1\leq M\leq 100000,1 \leq Q \leq 100000$.

It is guaranteed that the original graph is connected.

Translated by ChatGPT 5