* 无向图的割边将图分为不连通的两部分
* 对于是否有不想交的两条路径将s -> t 相连
* 只需判断是否处于同一部分
* Tarjan即可
#include <bits/stdc++.h> const int N = ; int Low[N], Dfn[N], Bel[N], Stack[N], topp;
struct Node {int u, v, nxt;} G[(int)1e5 + ];
int now, head[N];
int n, m;
bool vis[N]; #define gc getchar() inline int read() {
int x = ; char c = gc;
while(c < '' || c > '') c = gc;
while(c >= '' && c <= '') x = x * + c - '', c = gc;
return x;
} inline void Add(int u, int v) {
G[++ now].v = v; G[now].nxt = head[u]; head[u] = now;
} int clo, Bel_; void Tarjan(int u, int fa) {
Low[u] = Dfn[u] = ++ clo;
Stack[++ topp] = u; vis[u] = ;
for(int i = head[u]; ~ i; i = G[i].nxt) {
int v = G[i].v;
if(!Dfn[v]) {
Tarjan(v, u);
Low[u] = std:: min(Low[u], Low[v]);
} else
if(vis[v] && v != fa) Low[u] = std:: min(Low[u], Low[v]);
}
/*if(Low[u] == Dfn[u]) {
++ Bel_;
while(Low[Stack[topp]] == Low[u]) {
vis[Stack[topp]] = 0, Bel[Stack[topp]] = Bel_, topp --;
}
}*/
if(Low[u] == Dfn[u]) {
++ Bel_;
vis[u] = , Bel[u] = Bel_;
while(Stack[topp] != u) {
vis[Stack[topp]] = ;
Bel[Stack[topp]] = Bel_;
topp --;
} topp --;
}
} int main() {
n = read(), m = read();
for(int i = ; i <= n; i ++) head[i] = -;
for(int i = ; i <= m; i ++) {
int u = read(), v = read();
Add(u, v), Add(v, u);
}
for(int i = ; i <= n; i ++) {
if(!Dfn[i]) Tarjan(i, );
}
int Q = read();
for(; Q; Q --) {
int s = read(), t = read();
if(Bel[s] == Bel[t]) puts("Yes");
else puts("No");
}
return ;
}