8532: Fief

内存限制:1024 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

Duke NIO had 2 sons, Antileaf and Fstqwq, and they would inherit Duke NIO's fief. Duke NIO's fief was composed of n cities, and there were m bi-direction roads connecting these cities. For fairness, Duke NIO made the following rules for Antileaf and Fstqwq when inheriting his fief:


Firstly, both Antileaf and Fstqwq could choose a favorite city.


Then, according to the two favorite cities, Duke NIO would make a list. The content of the list is his n cities, and the first item of the list is Antileaf's favorite city while the last item of the list is Fstqwq's favorite city.


After that, Antileaf and Fstqwq could begin to inherit his fief. The number of cities each one would get should be determined by drawing a lot. For instance, Antileaf would get the first a cities in NIO's list (a is uniformly random between 1 and n−1) while Fstqwq would get the last n−a cities.


After all the cities were assigned to his two sons, each son's fief should be a connected component.

 
However, he found that in some cases, he couldn't find a list that meet his requirement. He came out with some questions - if Antileaf chose city x as his favorite city and Fstqwq chose city y, could he always find a list such that Antileaf and Fstqwq's fief would be always connected regardless of the result of the lottery?

输入格式

The first line contains two integers n and m (2≤n≤100000, 0≤m≤200000), denoting the number of cities and the number of roads. Then follows m lines, each line contains two integers ui and vi(1≤ui,vi≤n,ui≠vi), denotes the roads.


After that follows a line with a single integer q(1≤q≤100000), which denotes the number of NIO's queries. And then follows q lines, each line contains two integers xi and yi(1≤xi,yi≤n,xi≠yi), the meaning is described above.

输出格式

Output q lines. For the i-th line, if the answer of the i-th query is true, print "YES" (excluding quotes), otherwise print "NO" (excluding quotes).

输入样例 复制

4 3
1 2
2 3
4 3
3
1 3
4 1
3 4

输出样例 复制

NO
YES
NO

数据范围与提示

For the second query, the only valid list is [4,3,2,1].

分类标签