# 207. 共价大爷游长沙

input

0
5 7
1 2
1 3
2 4
1 5
2 1 5
1 1 5 2 5
4 2 5
2 1 4
4 2 5
3 1
4 2 4

output

YES
NO
YES

explanation

1 n≤100n≤100 m≤100m≤100 1,2,3,41,2,3,4
2 n≤100000n≤100000 m≤300000m≤300000 2,42,4
3
4 2,3,42,3,4
5
6 1,2,3,41,2,3,4 任意时刻 |S|≤10|S|≤10
7
8
9
10

matthew99

## sol:

ps:1A还是非常舒服的，就是第一遍NO输出成了No

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
using namespace std;

{
char c;
bool pd=0;
while((c=getchar())>'9'||c<'0')
if(c=='-') pd=1;
int res=c-'0';
while((c=getchar())>='0'&&c<='9')
res=(res<<3)+(res<<1)+c-'0';
return pd?-res:res;
}
const int N=310000;
int n,m,tmp,ans;
int sum1[N],sum2[N];
int val[N],lc[N],rc[N],fa[N];
int key[N],tkey;
inline void updata(int x)
{
sum1[x]=sum2[x]^sum1[lc[x]]^sum1[rc[x]]^val[x];
}
inline void rotate(int x)
{
int y=fa[x],z=fa[y];
int b=lc[y]==x?rc[x]:lc[x];
if(b) fa[b]=y;
fa[x]=z;fa[y]=x;
if(z)
{
if(lc[z]==y) lc[z]=x;
if(rc[z]==y) rc[z]=x;
}
if(lc[y]==x) rc[x]=y,lc[y]=b;
else lc[x]=y,rc[y]=b;
updata(y);
}
int rev[N];
inline void tag_rev(int x)
{
rev[x]=!rev[x];
swap(lc[x],rc[x]);
}
inline void tag_down(int x)
{
if(rev[x])
{
tag_rev(lc[x]);
tag_rev(rc[x]);
rev[x]=0;
}
}
int sta[N];
inline bool is_root(int x)
{
return lc[fa[x]]!=x&&rc[fa[x]]!=x;
}
inline void splay(int x)
{
sta[sta[0]=1]=x;
for(int y=x;!is_root(y);y=fa[y]) sta[++sta[0]]=fa[y];
while(sta[0]) tag_down(sta[sta[0]--]);
while(!is_root(x))
{
if(!is_root(fa[x]))
{
if((lc[fa[fa[x]]]==fa[x])==(lc[fa[x]]==x)) rotate(fa[x]);
else rotate(x);
}
rotate(x);
}
updata(x);
}
inline void access(int q)
{
for(int p=0;q;p=q,q=fa[q])
{
splay(q);
sum2[q]^=sum1[rc[q]];
rc[q]=p;
sum2[q]^=sum1[rc[q]];
updata(q);
}
}
inline void make_root(int x)
{
access(x);
splay(x);
tag_rev(x);
}
{
make_root(x);
access(y);
splay(y);
fa[x]=y;
sum2[y]^=sum1[x];
updata(y);
}
inline void cut(int x,int y)
{
make_root(x);
access(y);
splay(x);
rc[x]=fa[y]=0;
updata(x);
}
struct cc
{
int x,y,z;
}a[N];
int an;
int main()
{
//  freopen("207.in","r",stdin);
int x,y;
srand(time(0));
for(int i=2;i<=n;++i)
{
}
int tp,u,v;
for(int i=1;i<=m;++i)
{
if(tp==1)
{
cut(x,y);
}
if(tp==2)
{
++an;
a[an].z=rand()<<15|rand();
make_root(x);
sum1[x]^=a[an].z;
val[x]^=a[an].z;
make_root(y);
sum1[y]^=a[an].z;
val[y]^=a[an].z;
tkey^=a[an].z;
}
if(tp==3)
{
x=a[v].x;
y=a[v].y;
u=a[v].z;
make_root(x);
val[x]^=u;
sum1[x]^=u;
make_root(y);
val[y]^=u;
sum1[y]^=u;
tkey^=u;
}
if(tp==4)
{