Denis, Eugene and Misha take professional approach to ACM ICPC. They
don't have any common interests and communicate with each other only
during the competitions. Recently they arrived in Saint Petersburg to
participate in the regional contest and haven't seen each other yet.
At morning before the contest they will leave their hotel at different times
and will go to the contest site, Anichkov palace. Help them find out
if there are such three paths from the hotel to Anichkov palace, that
no two of them share a common road segment.
Input
The first line contains integers n and k (2 ≤ n ≤ 50000;
1 ≤ k ≤ 50000), which are the number of crossroads and the number of road segments in Saint Petersburg,
respectively. Crossroads are numbered with integers from 1 to n.
Each of the following k lines contains two different integers, which are the
numbers of crossroads, connected by a road segment. All road segments are bidirectional.
There is at most one road segment between any
two crossroads. The next line contains the number of test cases q
(1 ≤ q ≤ 50000). Each of the following q lines contains
two different integers, which are the numbers of crossroads, where the hotel and
Anichkov palace are situated, respectively.
Output
For each test case output “Yes” if there are three such paths that no two
of them share a common road segment. Otherwise, output “No”.
Sample
input | output |
---|
6 9
1 2
1 5
1 4
1 6
2 3
3 4
3 5
4 5
4 6
9
1 2
1 3
1 5
2 4
5 6
3 6
3 4
2 6
2 3
| No
Yes
Yes
No
No
No
Yes
No
No
|
Problem Source: Tavrida NU Akai Contest. Petrozavodsk Summer Session, August 2010