J. Avengers: Infinite War
题号:NC15732
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

请注意,虽然在正式题面中,这题的输出不区分大小写,但是,受限于SPJ的必要性,在同步赛上,本题的输出将严格匹配大小写,请注意以免造成不必要的罚时 

As the Avengers and their allies have continued to protect the world from threats too large for any one hero to handle, a new danger has emerged from the cosmic shadows: Thanos. A despot of intergalactic infamy, his goal is to collect all six Infinity Stones, artifacts of unimaginable power, and use them to inflict his twisted will on all of reality. Everything the Avengers have fought for has led up to this moment-the fate of Earth and existence itself has never been more uncertain.

During this war, the battle of the earth takes place in Wakanda, Black Panther and Captain America will lead superheroes to resist the Black Order.The infantry, led by captain, formed a defensive network in which there could be an undirected energy membrane between any two soldiers,because the fighting is so intense, the energy membrane may be destroyed at some point and then reborn at some point.Want to beat Thanos’ corporation, at any time Captain America need to know the status of the every soldier on the battlefield, such as how many people are there in the energy area Black widow belongs to,and whether any two soldiers are in the same energy area.Energy area is a subset of soldiers, in which any two soldiers can be connected directly or indirectly through the energy membrane,this task is a bit complicated, so captain wants you, Dr. Banner who has seven doctorates to help him finish this job, you will be fighting the Black Dwarf later, so please solve the problem as soon as possible.

输入描述:

The first line has a number n () to indicate the number of soldiers.

The second line has a number m () means there would be $m$ events.

Each of the following $m$ lines will be one of the four types below:


1 x y : At this point the energy film appears between x and y. ()


2 x y: At this point the energy film between x and y is destroyed.()


3 x : Captain wants to know how many people are there the energy area x belongs to.


4 x y: Whether $x$ and $y$ belong to the same energy area,output ``'' () if the ans is yes,otherwise output ``''.

输出描述:

Output one line of answer for each query.
请注意,虽然在正式题面中,这题的输出不区分大小写,但是,受限于SPJ的必要性,在同步赛上,本题的输出将严格匹配大小写,请注意以免造成不必要的罚时
示例1

输入

复制
5
7
1 1 2
1 2 3
3 1
1 1 4
4 1 5
2 2 3
3 2

输出

复制
3
No
3