To help capture criminals on the run, the police are introducing a new computer system. The area covered by the police contains
The police often want to catch criminals trying to get from one city to another. Inspectors, looking at a map, try to determine where to set up barricades and roadblocks. The new computer system should answer the following two types of queries:
- Consider two cities
and , and a road connecting cities and . Can the criminals get from city to city if that one road is blocked and the criminals can't use it? - Consider three cities
, and . Can the criminals get from city to city if the entire city is cut off and the criminals can't enter that city?
Write a program that implements the described system.
Input Specification
The first line contains two integers
Each of the following
The following line contains the integer
Each of the following 1
or 2
.
If the query is of type
If the query is of type
The test data will be such that it is initially possible to get from each city to every other city.
Output Specification
Output the answers to all yes
or no
.
Note: if your program correctly answers all questions of one type but not the other, it will receive 50% of the score for that case. Even then your program needs to answer all
Sample Input
13 15
1 2
2 3
3 5
2 4
4 6
2 6
1 4
1 7
7 8
7 9
7 10
8 11
8 12
9 12
12 13
5
1 5 13 1 2
1 6 2 1 4
1 13 6 7 8
2 13 6 7
2 13 6 8
Sample Output
yes
yes
yes
no
yes
Comments