mod = 998244353 def main(): import sys from collections import deque input = sys.stdin.buffer.readline # return: articulation points, bridges # The graph must be connected. def lowlink(adj, root=1): N = len(adj) - 1 order = [N + 1] * (N + 1) low = [N + 1] * (N + 1) AP = [] bridge = [] st = [root] cnt = 1 par = [0] * (N + 1) seq = [] while st: v = st.pop() if order[v] != N + 1: continue order[v] = cnt seq.append(v) low[v] = cnt cnt += 1 for u in adj[v]: if order[u] < cnt: if par[v] != u: low[v] = min(low[v], order[u]) continue else: par[u] = v st.append(u) child = [[] for _ in range(N + 1)] for v in range(1, N + 1): child[par[v]].append(v) seq.reverse() for v in seq: for u in child[v]: low[v] = min(low[v], low[u]) # bridge for p in range(1, N + 1): for c in child[p]: if order[p] < low[c]: bridge.append((p, c)) # articulation point for v in range(1, N + 1): if v == root: if len(child[v]) > 1: AP.append(v) else: for c in child[v]: if order[v] <= low[c]: AP.append(v) break return AP, bridge # idx_new[v]: adj_new(二辺連結成分分解後のグラフ)で元のグラフのvがどの頂点に入るか def two_edge_connected_components(adj, bridge): N = len(adj) - 1 cnt = 0 idx_new = [-1] * (N + 1) seen = [0] * (N + 1) B = set() for u, v in bridge: B.add(u * (N + 1) + v) B.add(v * (N + 1) + u) for v0 in range(1, N + 1): if seen[v0]: continue seen[v0] = 1 st = [v0] cnt += 1 while st: v = st.pop() idx_new[v] = cnt for u in adj[v]: if not seen[u]: if v * (N + 1) + u in B: continue seen[u] = 1 st.append(u) adj_new = [[] for _ in range(cnt + 1)] for u, v in bridge: u_new = idx_new[u] v_new = idx_new[v] adj_new[u_new].append(v_new) adj_new[v_new].append(u_new) return adj_new, idx_new class UnionFind(): def __init__(self, n): self.n = n self.root = [-1] * (n + 1) self.rnk = [0] * (n + 1) def find_root(self, x): while self.root[x] >= 0: x = self.root[x] return x def unite(self, x, y): x = self.find_root(x) y = self.find_root(y) if x == y: return elif self.rnk[x] > self.rnk[y]: self.root[x] += self.root[y] self.root[y] = x else: self.root[y] += self.root[x] self.root[x] = y if self.rnk[x] == self.rnk[y]: self.rnk[y] += 1 def isSameGroup(self, x, y): return self.find_root(x) == self.find_root(y) def size(self, x): return -self.root[self.find_root(x)] N, M, Q = map(int, input().split()) adj_ori = [[] for _ in range(N + 1)] UF_ori = UnionFind(N) for _ in range(M): a, b = map(int, input().split()) adj_ori[a].append(b) adj_ori[b].append(a) UF_ori.unite(a, b) adj_dict = {} idx_dict = {} UF = UnionFind(N) seen = [0] * (N + 1) V0 = [-1] * (N + 1) OK_XY = set() for v0 in range(1, N + 1): if seen[v0]: continue que = deque() que.append(v0) seen[v0] = 1 seq = [] while que: v = que.popleft() V0[v] = v0 seq.append(v) for u in adj_ori[v]: if not seen[u]: que.append(u) seen[u] = 1 idx = {v: i+1 for i, v in enumerate(seq)} idx_dict[v0] = idx NN = len(seq) adj = [[] for _ in range(NN + 1)] for v in seq: i = idx[v] for u in adj_ori[v]: j = idx[u] adj[i].append(j) adj_dict[v0] = adj AP, bridge = lowlink(adj, root=1) for u, v in bridge: uu, vv = seq[u - 1], seq[v - 1] UF.unite(uu, vv) """ adj_new, idx_new = two_edge_connected_components(adj, bridge) NNN = len(adj_new) - 1 cnt = [0] * (NNN + 1) v_convert = {} ii = 0 for v in idx_new[1:]: ii += 1 cnt[v] += 1 v_convert[v] = ii V_OK = [] for v in range(1, NNN + 1): if cnt[v] == 1: V_OK.append(v) for v in V_OK: v_ori = v_convert[v] for u in adj[v_ori]: vv = seq[v_ori - 1] uu = seq[u - 1] UF.unite(vv, uu) E = set() for v in range(1, NNN + 1): for u in adj_ori[v]: E.add(v * (N + 1) + u) for v in range(1, NN + 1): for u in adj[v]: vv = seq[v - 1] uu = seq[u - 1] i = idx_new[v] j = idx_new[u] if i * (N + 1) + j in E: OK_XY.add(vv * (N + 1) + uu) OK_XY.add(uu * (N + 1) + vv) UF.unite(uu, vv) """ for _ in range(Q): x, y = map(int, input().split()) if not UF_ori.isSameGroup(x, y): print("No") continue if UF.isSameGroup(x, y): print("Yes") else: print("No") #xy = x * (N + 1) + y #if xy in OK_XY: # print("Yes") #else: # print("No") print(UF.root, file=sys.stderr) if __name__ == '__main__': main()