Time limit
2s
Memory limit
512 MB
A country has N cities and E bidirectional roads, each connecting two different cities. The cities are numbered from 1 to N. If a road connects two cities, it can be used in both directions.
The country wants to simplify this complex traffic system. There are two possible operations: remove one chosen road, or choose one city and remove every road entering or leaving that city.
Several questions are given to check how these operations affect reachability. Each question is one of the following two types.
Given the current traffic system and all questions, write a program that answers each question.
The first line contains the number of cities N and the number of roads E. (2 <= N <= 100,000, 1 <= E <= 500,000)
Each of the next E lines contains the numbers of two different cities connected by a road. No road is given more than once, and the given traffic system always has at least one path between every pair of cities.
The next line contains the number of questions Q. (1 <= Q <= 300,000)
Each of the next Q lines contains one question. The first number on the line is the question type, either 1 or 2.
1 A B G1 G2. A and B are different, and a road between G1 and G2 always exists.2 A B C. A, B, and C are all different cities.For each question, print one answer on its own line. Print yes if travel is still possible after the simplification, and no otherwise.