Unbreakable Routes (medium version)
A network has n routers, numbered from 1 to n, and m cables. Each cable joins two different routers and carries traffic in both directions. Two routers may be joined by several cables, and the network does not have to be connected.
Two routers u and v are unbreakable if traffic can get from u to v now, and it still can after any single cable is cut, no matter which cable that is. A router is always unbreakable with itself.
Answer q queries: for each pair u, v, decide whether they are unbreakable.
Input
The first line contains two integers n and m (1 ≤ n ≤ 2·10^5, 0 ≤ m ≤ 2·10^5), the number of routers and cables.
Each of the next m lines contains two integers a_i and b_i (1 ≤ a_i, b_i ≤ n, a_i ≠ b_i): cable i joins routers a_i and b_i. The same pair of routers may appear several times.
The next line contains one integer q (1 ≤ q ≤ 2·10^5), the number of queries.
Each of the next q lines contains two integers u and v (1 ≤ u, v ≤ n). u and v may be equal.
Output
For each query, print YES on its own line if u and v are unbreakable, and NO otherwise.
Notes
In the first example, routers 1, 2 and 3 form a ring, so any two of them stay connected when one cable is cut. Cable 3–4 is the only way to reach router 4, so cutting it separates 4 from the rest. Routers 4 and 5 are joined by two cables, so cutting one leaves the other. Router 6 has no cables at all and only reaches itself.
In the second example, the routers form the line 1–2–3–4. Cutting cable 1–2 or cable 3–4 breaks the routes that use it, but routers 2 and 3 are joined by two parallel cables, so no single cut separates them.