Graph? Are you sure?
Initially, there are vertexes and no edges. Each of the added edges has an integer written on it. We define a simple path between two vertexes and , which belong to the same component, as the shortest path from to . Consider a simple path between two vertexes being good if each value on this path has the even number of entries. You have to answer queries of types:
() — add edge that connects vertexes and with value on it
— tell if the simple path between vertexes and is good. If there is no path between them, print
— tell the number of pairs of vertexes and (), such that they belong to the same component with and the path between them is considered good
— tell the number of pairs of vertexes and (), such that the path between them is considered good, and there exists a path from to .
It is guaranteed that in all queries of the first type, the edge connects two different components.
Input
The first line of input contains two integers () and () — the number of vertices and queries accordingly.
Each of the following lines contain a description of the query. First integer defines the type of the query.
defines a query of the first type and is followed by integers , (), ()
defines a query of the second type and is followed by integers , ()
defines a query of the third type and is followed by integer ()
defines a query of the fourth type.
Output
For each query of type print
-1
, if there is no existing simple pathYES
, if the simple path is considered goodNO
otherwise.
For each query of types or print one integer — answer for corresponding query.
You have to answer queries in order they appear in the input.
Examples
Scoring
( points): for all ;
( points): ;
( points): ;
( points): , , ;
( points): , , ;
( points): , ;
( points): , for , ;
( points): there exists integer such that all for all , and for all ;
( points): , graph and tests are generated randomly, i.e., for each vertex () we randomly choose (), then we generate random permutation and make , . Type of query is chosen randomly (we won't choose first type if there are no edges to add). All values in queries are picked randomly;
( points): no additional restrictions.