# [bzoj2049][Sdoi2008]Cave 洞穴勘测

n<=10000  m<=200000

#include<iostream>
#include<cstdio>
#define MN 10000
using namespace std;
{
int x = 0 , f = 1; char ch = getchar();
while(ch < '0' || ch > '9'){ if(ch == '-') f = -1;  ch = getchar();}
while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
return x * f;
}

int n,m,fa[MN+5],c[MN+5][2],rev[MN+5],q[MN+5],top;
char op[20];

inline bool isroot(int x){return c[fa[x]][0]!=x&&c[fa[x]][1]!=x;}

void pushdown(int x)
{
if(rev[x])
{
rev[x]^=1;rev[c[x][0]]^=1;rev[c[x][1]]^=1;
swap(c[x][0],c[x][1]);
}
}

void rotate(int x)
{
int y=fa[x],z=fa[y],l=c[y][1]==x,r=l^1;
if(!isroot(y)) c[z][c[z][1]==y]=x;
fa[x]=z;fa[y]=x;fa[c[x][r]]=y;
c[y][l]=c[x][r];c[x][r]=y;
}

void splay(int x)
{
q[top=1]=x;
for (int i=x;!isroot(i);) q[++top]=i=fa[i];
for(int i=top;i;i--) pushdown(q[i]);
while(!isroot(x))
{
int y=fa[x],z=fa[y];
if(!isroot(y))
{
if(c[y][1]==x^c[z][1]==y) rotate(x);
else rotate(y);
}
rotate(x);
}
}

void access(int x)
{
for(int y=0;x;x=fa[y=x])
splay(x),c[x][1]=y;
}

{
access(x);splay(x);rev[x]^=1;
access(y);c[y][1]=x;fa[x]=y;
}

void cut(int x,int y)
{
access(x);splay(x);rev[x]^=1;
access(y);splay(y);c[y][0]=fa[x]=0;
}

int find(int x)
{
access(x);splay(x);
for(;c[x][0];x=c[x][0]);
return x;
}

int main()
{
}